Harden npm trusted publishing workflow #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| on: [push, pull_request] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: π§ͺ Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: β¬οΈ Checkout repo | |
| uses: actions/checkout@v5 | |
| - name: π Setup bun | |
| uses: oven-sh/setup-bun@v1 | |
| - name: π₯ Download deps | |
| run: bun install | |
| - name: π§ͺ Test | |
| run: bun test | |
| build-release-artifact: | |
| name: π¦ Build release artifact | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| if: | |
| ${{ github.repository == 'epicweb-dev/remember' && | |
| contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha', | |
| github.ref) && github.event_name == 'push' }} | |
| steps: | |
| - name: β¬οΈ Checkout repo | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| - name: β Setup node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: lts/* | |
| package-manager-cache: false | |
| - name: π₯ Install deps | |
| run: npm install --ignore-scripts | |
| - name: π¦ Prepare package | |
| run: npx -p typescript tsc --declaration --emitDeclarationOnly --allowJs --checkJs --downlevelIteration --module nodenext --moduleResolution nodenext --target es2022 --outDir . index.js | |
| - name: π¦ Upload package artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: npm-package-artifact | |
| path: index.d.ts | |
| if-no-files-found: error | |
| retention-days: 1 | |
| release: | |
| name: π Release | |
| needs: [build-release-artifact] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # to be able to publish a GitHub release | |
| id-token: write # to enable use of OIDC for npm provenance | |
| issues: write # to be able to comment on released issues | |
| pull-requests: write # to be able to comment on released pull requests | |
| if: | |
| ${{ github.repository == 'epicweb-dev/remember' && | |
| contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha', | |
| github.ref) && github.event_name == 'push' }} | |
| steps: | |
| - name: β¬οΈ Checkout repo | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| - name: β Setup node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| package-manager-cache: false | |
| - name: π¦ Download package artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| name: npm-package-artifact | |
| path: . | |
| - name: π Release | |
| uses: cycjimmy/semantic-release-action@ba330626c4750c19d8299de843f05c7aa5574f62 # v5.0.2 | |
| with: | |
| semantic_version: 25 | |
| branches: | | |
| [ | |
| '+([0-9])?(.{+([0-9]),x}).x', | |
| 'main', | |
| 'next', | |
| 'next-major', | |
| {name: 'beta', prerelease: true}, | |
| {name: 'alpha', prerelease: true} | |
| ] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: true | |
| NPM_CONFIG_IGNORE_SCRIPTS: true |