From c241f5f40e0476f2f5098bd42f8dea44fe0d3221 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:11:08 +0000 Subject: [PATCH 1/7] 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 c907a75f0..729067b63 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 From 477f014b8ca2a8de7c84fd1a04a9e8b90068da6c Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:11:53 +0000 Subject: [PATCH 2/7] Add token permissions --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 729067b63..0b3e27aa4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,10 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'release' needs: build + + permissions: + contents: write + steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 5b274ff84a11f1b3fb1aaedb4564aea01d80e92f Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:12:35 +0000 Subject: [PATCH 3/7] Test workflow --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0b3e27aa4..0c975bf7b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,29 @@ jobs: - run: npm test - run: npm run lint + package-test: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/justin/publish-packs' + + permissions: + contents: write + + 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 0.1.0 ./*.tgz + package: runs-on: ubuntu-latest if: github.event_name == 'release' From aa9f835ddb30684190557c673aa1e867882df017 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:13:57 +0000 Subject: [PATCH 4/7] Need head_ref --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c975bf7b..bc772c800 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: package-test: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/justin/publish-packs' + if: github.head_ref == 'refs/heads/justin/publish-packs' permissions: contents: write From 6e868d1d7173db7c1398029d11af8f3c83514d84 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:15:35 +0000 Subject: [PATCH 5/7] Cancel in-progress builds automatically --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc772c800..efc23b1eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,10 @@ on: release: types: [created] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest From 9eeaf3e44eb29baed5617b36aeeae3b5650287a5 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:16:08 +0000 Subject: [PATCH 6/7] Just remove the 'if' for testing --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efc23b1eb..16092e59e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,6 @@ jobs: package-test: runs-on: ubuntu-latest - if: github.head_ref == 'refs/heads/justin/publish-packs' permissions: contents: write From 8e07474f5251253a05c50e3034307385b1e66872 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 29 Oct 2024 12:17:20 +0000 Subject: [PATCH 7/7] Remove test job --- .github/workflows/main.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16092e59e..3335e5c38 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,28 +26,6 @@ jobs: - run: npm test - run: npm run lint - package-test: - runs-on: ubuntu-latest - - permissions: - contents: write - - 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 0.1.0 ./*.tgz - package: runs-on: ubuntu-latest if: github.event_name == 'release'