Skip to content

Commit 61caa52

Browse files
suboss87claude
andauthored
release: publish through npm trusted publishing on Node 24 (#174)
Every tag-triggered publish since 5.2.x failed with E404 on PUT, the npm response for a token without publish rights, so releases were published by hand. Publish with OIDC trusted publishing instead of the NPM_TOKEN secret, move to Node 24, and refuse early when npm is older than 11.5.1. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1e1e104 commit 61caa52

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@ jobs:
1717
runs-on: ubuntu-latest
1818
permissions:
1919
contents: read
20-
id-token: write # npm provenance
20+
id-token: write # npm trusted publishing (OIDC) and provenance
2121
steps:
2222
- uses: actions/checkout@v4
2323

2424
- uses: actions/setup-node@v4
2525
with:
26-
node-version: "20"
26+
node-version: "24"
2727
registry-url: "https://registry.npmjs.org"
2828

29+
- name: npm supports trusted publishing
30+
run: |
31+
v=$(npm --version)
32+
echo "npm $v"
33+
node -e "const [a,b,c]=process.argv[1].split('.').map(Number);process.exit(a>11||(a===11&&(b>5||(b===5&&c>=1)))?0:1)" "$v" \
34+
|| { echo "refusing: trusted publishing needs npm >= 11.5.1"; exit 1; }
35+
2936
- name: The tag and package.json agree
3037
run: |
3138
pkg=$(node -p "require('./package.json').version")
@@ -44,10 +51,10 @@ jobs:
4451
echo "refusing: fdeops@$pkg is already published"; exit 1
4552
fi
4653
54+
# Authenticates through npm trusted publishing: the package's trusted publisher on
55+
# npmjs.com must name this repository and release.yml. No long-lived token is used.
4756
- name: Publish
4857
run: npm publish --provenance --access public
49-
env:
50-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5158

5259
- name: Confirm the registry serves it
5360
timeout-minutes: 12

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The release workflow publishes to npm when a version tag is pushed, or when manu
6767
2. Run `npm run check` and review the release diff.
6868
3. Merge the reviewed change to `Main`; tag that commit as `v<package-version>` and push the tag when ready to publish.
6969

70-
[The workflow](.github/workflows/release.yml) checks version agreement, runs the gate, refuses an already-published version, publishes with provenance using the repository's `NPM_TOKEN` secret, and checks the registry result. Configure that secret with a currently supported npm publishing credential scoped to this package.
70+
[The workflow](.github/workflows/release.yml) checks version agreement, runs the gate, refuses an already-published version, publishes with provenance through npm trusted publishing, and checks the registry result. The package's trusted publisher on npmjs.com must name this repository and `release.yml`; no long-lived npm token is stored.
7171

7272
---
7373

0 commit comments

Comments
 (0)