From 4493d36996823813657b7c7f31d47462e9f53614 Mon Sep 17 00:00:00 2001 From: Will Gosnold Date: Tue, 27 Oct 2026 17:26:18 +0100 Subject: [PATCH] ci(release): publish to npm with trusted publishing instead of a token Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c13ca797..7635eda0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -151,6 +151,16 @@ jobs: run: scripts/smoke-npm.sh dist/npm linux-x64 "$VERSION" env: VERSION: ${{ needs.build.outputs.version }} + # Publishing authenticates with this job's OIDC token through npm trusted publishing, so + # there is no npm token. Each package trusts this repo's release.yml on npmjs.com. + - name: Check npm supports trusted publishing + run: | + need=11.5.1 + have=$(npm --version) + if [[ "$(printf '%s\n' "$need" "$have" | sort -V | head -1)" != "$need" ]]; then + echo "::error::npm $have can't use trusted publishing, which needs npm $need or later" + exit 1 + fi - name: Publish the platform packages, then patchbook run: | tag=latest @@ -161,7 +171,7 @@ jobs: echo "$name@$VERSION is already published" return fi - npm publish "$1" --provenance --access public --tag "$tag" + npm publish "$1" --access public --tag "$tag" } for dir in dist/npm/*/; do [[ "$dir" == dist/npm/patchbook/ ]] || publish "${dir%/}" @@ -169,4 +179,3 @@ jobs: publish dist/npm/patchbook env: VERSION: ${{ needs.build.outputs.version }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}