From 545e67088574b435b68e94d1e154890fc0f4a7f8 Mon Sep 17 00:00:00 2001 From: aimee rivers Date: Tue, 28 Nov 2023 14:45:51 +0100 Subject: [PATCH] feat(workflows): switch to an integrated release-and-publish workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this is needed because events triggered by a GITHUB_TOKEN do not create new workflow runs. a sad day for automation 🥲 --- .github/workflows/publish-please.yml | 49 ------------------ .github/workflows/release-and-publish.yml | 62 +++++++++++++++++++++++ .github/workflows/release-please.yml | 22 -------- 3 files changed, 62 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/publish-please.yml create mode 100644 .github/workflows/release-and-publish.yml delete mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/publish-please.yml b/.github/workflows/publish-please.yml deleted file mode 100644 index 4181772..0000000 --- a/.github/workflows/publish-please.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Publish Please - -on: - workflow_call: - inputs: - github_ref: - description: The git ref to publish - type: string - required: true - secrets: - READONLY_NPM_TOKEN: - description: Needed to install private @hedia npm packages - required: true - PUBLISHING_NPM_TOKEN: - description: Needed to publish @hedia npm packages - required: true - -jobs: - publish-please: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - with: - ref: ${{ inputs.github_ref }} - fetch-depth: 1 - - - name: Setup Node.js Environment - uses: actions/setup-node@v3 - with: - node-version-file: "package.json" - always-auth: true - registry-url: https://registry.npmjs.org - scope: "@hedia" - - - name: Install Dependencies - run: npm ci - env: - NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }} - - - name: Build - run: npm run build --if-present - - - name: Publish to npm - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.PUBLISHING_NPM_TOKEN }} diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml new file mode 100644 index 0000000..fa15150 --- /dev/null +++ b/.github/workflows/release-and-publish.yml @@ -0,0 +1,62 @@ +name: Release and Publish + +on: + workflow_call: + secrets: + READONLY_NPM_TOKEN: + description: Needed to install private @hedia npm packages + required: true + PUBLISHING_NPM_TOKEN: + description: Needed to publish @hedia npm packages + required: true + +permissions: + contents: write + pull-requests: write + +jobs: + release-and-publish: + runs-on: ubuntu-latest + if: > + github.event_name == 'workflow_dispatch' || + (github.event_name == 'pull_request' && + github.event.pull_request.merged == true && + contains(github.event.pull_request.labels.*.name, 'autorelease: pending') + ) + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: node + + - if: steps.release.outputs.release_created == 'true' + name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + fetch-depth: 1 + + - if: steps.release.outputs.release_created == 'true' + name: Setup Node.js Environment + uses: actions/setup-node@v3 + with: + node-version-file: "package.json" + always-auth: true + registry-url: https://registry.npmjs.org + scope: "@hedia" + + - if: steps.release.outputs.release_created == 'true' + name: Install Dependencies + run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }} + + - if: steps.release.outputs.release_created == 'true' + name: Build + run: npm run build --if-present + + - if: steps.release.outputs.release_created == 'true' + name: Publish to npm + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.PUBLISHING_NPM_TOKEN }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index c9ed137..0000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Release Please - -on: - workflow_call: - -permissions: - contents: write - pull-requests: write - -jobs: - release-please: - runs-on: ubuntu-latest - if: > - github.event_name == 'workflow_dispatch' || - (github.event_name == 'pull_request' && - github.event.pull_request.merged == true && - contains(github.event.pull_request.labels.*.name, 'autorelease: pending') - ) - steps: - - uses: google-github-actions/release-please-action@v3 - with: - release-type: node