Skip to content

Commit 330adf0

Browse files
fix(publish): R1 — 2 Cursor Bugbot High + CodeRabbit Minor on PR #36
Cursor Bugbot caught two genuine blockers that would have made the first release-after-merge fail at the npm publish step: 1. Node 20 too old for OIDC Trusted Publishing. npm Trusted Publishing requires npm CLI 11.5.1+ which ships with Node 22.14+. Node 20 bundles npm 10.x with no OIDC publish-auth path — would fail ENEEDAUTH. Bumped node-version: 20 → 22. 2. setup-node + registry-url writes _authToken=${NODE_AUTH_TOKEN} to ~/.npmrc. With NODE_AUTH_TOKEN unset, the empty auth line tricks npm into thinking auth is configured, so it SKIPS the OIDC token exchange. Added a sed step after setup-node that strips the stale //registry.npmjs.org/:_authToken= line so OIDC activates. Documented issue: actions/setup-node#1551. CodeRabbit Minor: AGENTS.md still said publishes use 'a CI-only NPM_TOKEN secret.' Rewrote that section to reflect the OIDC path + added a stronger warning against manual laptop publishes (referencing v0.2.7's unattested-release gap as the canonical example). Test plan: - npm test: 32 pass - First post-merge release will exercise the new path end-to-end - Post-publish attestation gate in publish.yml (unchanged) will fail loudly if anything is misconfigured Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 67f80e5 commit 330adf0

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,31 @@ jobs:
2626
# Pinned to commit SHA to prevent supply-chain attacks via tag re-pointing.
2727
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
2828

29+
# Node 22 is REQUIRED for Trusted Publishing OIDC. The npm CLI 11.5.1+
30+
# (bundled with Node 22.14+) added the OIDC token-exchange code path used
31+
# by trusted publishers. Node 20 ships npm 10.x which has no OIDC
32+
# publish-auth path — it would fail with ENEEDAUTH at the npm publish
33+
# step. Cursor Bugbot High caught this on R0; see PR #36.
2934
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3035
with:
31-
node-version: 20
36+
node-version: 22
3237
registry-url: https://registry.npmjs.org
3338

39+
# actions/setup-node writes `//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}`
40+
# to ~/.npmrc when given a registry-url. With NODE_AUTH_TOKEN unset (Trusted
41+
# Publishing), that line expands to an empty `_authToken=` value which npm
42+
# interprets as "auth already configured" and SKIPS the OIDC token exchange,
43+
# causing publish to fail with ENEEDAUTH. Stripping the stale auth line lets
44+
# the OIDC path activate. See actions/setup-node#1551 + Cursor Bugbot High
45+
# finding on PR #36 R0.
46+
- name: Strip stale _authToken line from .npmrc (so OIDC exchange activates)
47+
run: |
48+
set -euo pipefail
49+
if [ -f "${HOME}/.npmrc" ]; then
50+
sed -i.bak '/^\/\/registry\.npmjs\.org\/:_authToken=/d' "${HOME}/.npmrc"
51+
rm -f "${HOME}/.npmrc.bak"
52+
fi
53+
3454
- run: npm ci
3555

3656
- run: npm test

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ There is no test suite, no linter, and no build step. The package ships raw JS.
3636
Publishing is fully automated via GitHub Actions:
3737
1. Bump version in `package.json` + `server.json` and push to `main`
3838
2. `auto-release.yml` creates a GitHub Release from the version bump
39-
3. `publish.yml` publishes to npm with provenance using a CI-only `NPM_TOKEN` secret
39+
3. `publish.yml` publishes to npm with provenance via **npm Trusted Publishing** (GitHub Actions OIDC, no token needed). Trusted Publisher configured at npmjs.com for `trackly-app/trackly-cli` + `publish.yml` workflow.
4040

41-
**Do not run `npm publish` locally.** No local npm auth token is needed. If a manual publish is ever required as a break-glass measure, create a short-lived granular token just-in-time and revoke it immediately after.
41+
**Do not run `npm publish` locally.** Manual publishes from a laptop have no OIDC context and would ship without provenance (this is what created the v0.2.7 unattested-release gap). If a manual publish is ever absolutely required as a break-glass measure, document why on the next CHANGELOG entry and plan a cosmetic version bump immediately after to restore the attestation chain via CI.
4242

4343
## Key Patterns
4444

0 commit comments

Comments
 (0)