From c241f5f40e0476f2f5098bd42f8dea44fe0d3221 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:11:08 +0000 Subject: [PATCH] Automatically publish npm pack to GH Releases --- .github/workflows/main.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c907a75f..729067b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,8 +2,9 @@ on: push: branches: - main - pull_request: + release: + types: [created] jobs: build: @@ -18,9 +19,25 @@ jobs: - run: npm ci - run: npm run build - - - name: Verify that `npm run build` did not change outputs - run: git diff --exit-code - - run: npm test - run: npm run lint + + package: + runs-on: ubuntu-latest + if: github.event_name == 'release' + needs: build + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + + - run: npm ci + - run: npm pack + + - name: Upload package to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.event.release.tag_name }} ./*.tgz