From 221fe946912ca04a089dd8a86101a43d08999a24 Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Wed, 28 Feb 2024 15:56:58 -0800 Subject: [PATCH] Update GitHub actions (versions / ergonomics). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change set bumps the referenced / reusable GitHub actions to their latest versions, bumps node versions, and enables reuse of a “test” wf. --- .github/workflows/check-branch.yaml | 6 ++++++ .github/workflows/publish-to-npm.yaml | 23 +++++++++++++++++++++++ .github/workflows/publish.yaml | 12 ++++++++++++ .github/workflows/release.yml | 23 ----------------------- .github/workflows/{push.yml => test.yaml} | 17 ++++++++--------- 5 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/check-branch.yaml create mode 100644 .github/workflows/publish-to-npm.yaml create mode 100644 .github/workflows/publish.yaml delete mode 100644 .github/workflows/release.yml rename .github/workflows/{push.yml => test.yaml} (50%) diff --git a/.github/workflows/check-branch.yaml b/.github/workflows/check-branch.yaml new file mode 100644 index 0000000..50aaa0b --- /dev/null +++ b/.github/workflows/check-branch.yaml @@ -0,0 +1,6 @@ +# Run tests on pushes to all branches. +name: Check Branch +on: [push] +jobs: + test: + uses: ./.github/workflows/test.yaml diff --git a/.github/workflows/publish-to-npm.yaml b/.github/workflows/publish-to-npm.yaml new file mode 100644 index 0000000..a2fbe3f --- /dev/null +++ b/.github/workflows/publish-to-npm.yaml @@ -0,0 +1,23 @@ +# Publish package to npm whenever a release is pushed. +# See https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages +name: Publish to npm +on: + workflow_call: + inputs: + secrets: + NPM_TOKEN: + description: 'A token to enable this workflow to publish to npm.' + required: true +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..bb38d0f --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,12 @@ +# Run tests and publish to all registries if successful. +name: Publish +on: + release: + types: [published] +jobs: + test: + uses: ./.github/workflows/test.yaml + publish-to-npm: + needs: test + uses: ./.github/workflows/publish-to-npm.yaml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 06ae1f3..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Release -on: - release: - types: [created] -jobs: - test: - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - run: npm install - - run: npm run lint - - run: npm start & - - run: sleep 2 - - run: npm test - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/push.yml b/.github/workflows/test.yaml similarity index 50% rename from .github/workflows/push.yml rename to .github/workflows/test.yaml index 8b78278..28e5a38 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/test.yaml @@ -1,17 +1,16 @@ -name: Push -on: [push] +# Test flow triggered by other workflows. +name: Test +on: [workflow_call] jobs: - test: + main: runs-on: ubuntu-latest - permissions: - contents: read steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: '20.x' registry-url: 'https://registry.npmjs.org' - - run: npm install + - run: npm ci - run: npm run lint - run: npm start & - run: sleep 2