From 15fa1aca4d5f766ed25dd2b49d6bd70c5daddaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Fri, 25 Mar 2022 14:30:58 +0000 Subject: [PATCH 1/4] Create .github/workflows/publish.yml --- .github/workflows/publish.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..103f627 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Publish + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + cache: npm + - run: npm ci + - run: npm test + - run: npm version ${TAG_NAME} --git-tag-version=false + env: + TAG_NAME: ${{ github.event.release.tag_name }} + - run: npm whoami; npm --ignore-scripts publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} From 2b54659250512f12fa2b1f016ffd0b987d43ba23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Fri, 25 Mar 2022 14:31:00 +0000 Subject: [PATCH 2/4] Delete .github/workflows/release.yml --- .github/workflows/release.yml | 75 ----------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 11a2fe6..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Release and publish - -# Inspired by https://github.com/MylesBorins/node-osc/blob/959b9c83972a67390a351d333b23db3972ca7b46/.github/workflows/bump-version.yml and -# https://github.com/MylesBorins/node-osc/blob/74b563c83736a04c4a37acbff9d7bb1f01a00f57/.github/workflows/create-release.yml - -on: - workflow_dispatch: - inputs: - version: - description: Semver descriptor for new version ("major", "minor", or "patch") - required: true - -jobs: - bump-version: - name: Bump package version - runs-on: ubuntu-latest - outputs: - new-tag: ${{ steps.new-tag.outputs.new-tag }} - steps: - - name: Checkout ref - uses: actions/checkout@v2 - - name: Preparation - uses: ./.github/actions/setup - - name: Perform last-minute tests - run: npm test - - name: Configure Git - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - name: Bump package version - run: npm version ${{ github.event.inputs.version }} - - name: Push back to GitHub - run: git push origin main --follow-tags - - name: Set output to new version - id: new-tag - run: | - version=$(jq -r .version < package.json) - echo "::set-output name=new-tag::v$version" - create-release: - name: Create GitHub release - runs-on: ubuntu-latest - needs: bump-version - steps: - - name: Checkout ref - uses: actions/checkout@v2 - with: - ref: ${{ needs.bump-version.outputs.new-tag }} - - name: Preparation - uses: ./.github/actions/setup - - name: Create release - uses: actions/github-script@v5 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - await github.request(`POST /repos/${{ github.repository }}/releases`, { - tag_name: "${{ needs.bump-version.outputs.new-tag }}", - generate_release_notes: true - }) - publish: - name: Publish to npm - runs-on: ubuntu-latest - needs: [bump-version, create-release] - steps: - - name: Checkout ref - uses: actions/checkout@v2 - with: - ref: ${{ needs.bump-version.outputs.new-tag }} - - name: Preparation - uses: ./.github/actions/setup - - name: Build package - run: npm run build --if-present - - name: Publish - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From e65bba73194b5ca2073deaeeedb323d2a3c3ea34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Fri, 25 Mar 2022 14:31:43 +0000 Subject: [PATCH 3/4] Delete action.yml --- .github/actions/setup/action.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/actions/setup/action.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index 373a9f9..0000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Setup project -description: Sets up the repo code, Node.js, and npm dependencies - -runs: - using: composite - steps: - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '16.x' - cache: npm - registry-url: https://registry.npmjs.org - - name: Install npm dependencies - run: npm ci - shell: bash From 8246dc97811f0118aa8e6dedc8ab133b213d16ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Fri, 25 Mar 2022 14:33:48 +0000 Subject: [PATCH 4/4] Downgrade to node 14 --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 103f627..c1b229d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 14 registry-url: https://registry.npmjs.org/ cache: npm - run: npm ci