|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master"] |
| 6 | + |
| 7 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + id-token: write # Required for npm OIDC trusted publishing |
| 13 | + |
| 14 | +jobs: |
| 15 | + release: |
| 16 | + name: Release |
| 17 | + # Must use a GitHub-hosted runner — npm OIDC trusted publishing does not |
| 18 | + # support self-hosted runners at this time. |
| 19 | + # https://docs.npmjs.com/trusted-publishers/ |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + token: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - name: Install pnpm |
| 29 | + uses: pnpm/action-setup@v4 |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: '24' |
| 35 | + cache: 'pnpm' |
| 36 | + |
| 37 | + - name: Update npm |
| 38 | + # npm 11.5.1+ is required for OIDC trusted publishing support. |
| 39 | + # Pin to 11.x: npm 12.0.0 ships a broken bundle missing the `sigstore` |
| 40 | + # module in libnpmpublish, which breaks `publish --provenance` with |
| 41 | + # "Cannot find module 'sigstore'". |
| 42 | + run: npm install -g npm@11 |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: pnpm install --ignore-scripts |
| 46 | + |
| 47 | + - name: Build packages |
| 48 | + run: pnpm --filter benchsdk run build |
| 49 | + |
| 50 | + - name: Test |
| 51 | + run: pnpm --filter benchsdk run test |
| 52 | + |
| 53 | + - name: Create Release Pull Request or Publish to npm |
| 54 | + id: changesets |
| 55 | + uses: changesets/action@v1 |
| 56 | + with: |
| 57 | + # Provenance (signed attestations linking each package to this |
| 58 | + # workflow run) is configured via the NPM_CONFIG_PROVENANCE env var |
| 59 | + # below rather than a `--provenance` CLI flag, which @changesets/cli |
| 60 | + # does not support. |
| 61 | + publish: pnpm changeset publish |
| 62 | + title: "Version Packages" |
| 63 | + commit: "Version Packages" |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.CHANGESET_TOKEN || secrets.GITHUB_TOKEN }} |
| 66 | + # Sequence: (1) publish once with NPM_TOKEN, (2) configure the trusted |
| 67 | + # publisher for benchsdk on npmjs.com, (3) remove NPM_TOKEN from this |
| 68 | + # workflow in a follow-up. Trusted publishers require an existing |
| 69 | + # package on the registry, so OIDC cannot be used for the initial |
| 70 | + # publication. |
| 71 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 72 | + NPM_CONFIG_PROVENANCE: true |
0 commit comments