From 1b5dde03672562379fc21c227d607df235c7b44f Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 8 Jun 2026 21:29:10 +0100 Subject: [PATCH] ci: migrate release workflow to uppt --- .github/workflows/release.yml | 87 +++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59fa8e9..1833427 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,54 +2,71 @@ name: release on: push: - tags: - - 'v*' + branches: [main] + pull_request: + types: [closed] + branches: [main] + workflow_dispatch: -# Remove default permissions of GITHUB_TOKEN for security -# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs permissions: {} jobs: - release: - concurrency: - group: release + pr: + if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + runs-on: ubuntu-latest permissions: contents: write - id-token: write - runs-on: ubuntu-latest - timeout-minutes: 20 + pull-requests: write steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - fetch-depth: 0 - - run: corepack enable - - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + - uses: danielroe/uppt/pr@4e0c42a0fd6091f59e5dfe168e69b57651e87bed # v0.5.4 with: - node-version: lts/* + token: ${{ secrets.GITHUB_TOKEN }} - - name: 📦 Install dependencies - run: pnpm install --frozen-lockfile - - - name: 🛠 Build project - run: pnpm build - - - name: 📦 Release - run: pnpm publish --no-git-checks - - release-changelog: + release: + if: | + github.event_name == 'pull_request' + && github.event.pull_request.merged == true + && startsWith(github.event.pull_request.head.ref, 'release/v') + && github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest + concurrency: + group: release-${{ github.event.pull_request.number }} + cancel-in-progress: false permissions: contents: write + actions: write steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - uses: danielroe/uppt/release@4e0c42a0fd6091f59e5dfe168e69b57651e87bed # v0.5.4 with: - fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - - name: Set node - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 - with: - node-version: lts/* + pack: + if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + concurrency: + group: pack-${{ github.ref }} + cancel-in-progress: false + permissions: {} + outputs: + files: ${{ steps.pack.outputs.files }} + steps: + - id: pack + uses: danielroe/uppt/pack@4e0c42a0fd6091f59e5dfe168e69b57651e87bed # v0.5.4 - - run: npx changelogithub - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish: + if: | + github.event_name == 'workflow_dispatch' + && startsWith(github.ref, 'refs/tags/v') + && needs.pack.outputs.files != '[]' + needs: pack + runs-on: ubuntu-latest + concurrency: + group: publish-${{ github.ref }} + cancel-in-progress: false + permissions: + id-token: write + environment: npm + steps: + - uses: danielroe/uppt/publish@4e0c42a0fd6091f59e5dfe168e69b57651e87bed # v0.5.4 + with: + files: ${{ needs.pack.outputs.files }}