Skip to content

Commit 6a205d6

Browse files
authored
Merge pull request #19 from ar-io/ci/npm-trusted-publishing
ci: publish to npm via trusted publishing
2 parents 560a1fd + 69c5356 commit 6a205d6

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ jobs:
2121
needs: build
2222
permissions:
2323
contents: write # publish a GitHub release and push the release commit
24+
id-token: write # mint the OIDC token npm exchanges for a publish token
2425
issues: write # comment on released issues
2526
pull-requests: write # comment on released pull requests
2627
steps:
2728
- uses: actions/checkout@v4
2829
with:
29-
# A PAT (or GitHub App token) is required so the release commit/tag can
30-
# be pushed past the "changes must be made through a pull request"
31-
# branch ruleset. The token's actor must be in the ruleset bypass list.
32-
token: ${{ secrets.DEPLOY_PAT || github.token }}
30+
# @semantic-release/git pushes the `chore(release)` commit straight to
31+
# main, which the `two-stage` ruleset otherwise requires a PR for.
32+
# The GitHub Actions app (id 15368) is a bypass actor on that ruleset,
33+
# so the built-in token is sufficient — matching turbo-sdk, which runs
34+
# the same release with the plain GITHUB_TOKEN. No PAT to expire.
35+
# A push made with this token does not re-trigger workflows, and the
36+
# release commit carries [skip ci] regardless.
37+
token: ${{ github.token }}
3338
fetch-depth: 0
3439
fetch-tags: true
3540

@@ -51,9 +56,16 @@ jobs:
5156
- name: Build package
5257
run: pnpm build
5358

59+
# @semantic-release/npm prefers npm trusted publishing: it exchanges the
60+
# GitHub OIDC token above for a short-lived registry token, so no
61+
# long-lived npm credential is involved and the release carries a
62+
# provenance attestation. NODE_AUTH_TOKEN stays as the fallback — the
63+
# plugin only reaches for it when the OIDC exchange does not succeed, so
64+
# this is safe before the trusted publisher is registered on npmjs.com
65+
# and becomes dead weight once it is.
5466
- name: Release
5567
env:
56-
GITHUB_TOKEN: ${{ secrets.DEPLOY_PAT || github.token }}
68+
GITHUB_TOKEN: ${{ github.token }}
5769
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5870
HUSKY: '0'
5971
run: pnpm semantic-release

0 commit comments

Comments
 (0)