Skip to content

Commit 2871626

Browse files
dmealingclaude
andcommitted
ci(npm-dist-tag): setup-node's registry-url shadowed the npmrc the step writes
The workflow added yesterday failed its first real run with `E401 — Unable to authenticate, your authentication token seems to be invalid` on all fourteen packages, which reads as a dead `NPM_TOKEN` secret. It is not. `actions/setup-node` with `registry-url:` writes its own `.npmrc` and exports `NPM_CONFIG_USERCONFIG` pointing at it. That config wins over `~/.npmrc`, so the `~/.npmrc` the step writes from the secret is never read; npm authenticated with setup-node's un-expanded `${NODE_AUTH_TOKEN}` placeholder instead, and the registry rejected it. The run log shows both values side by side. The failure mode is worth naming because it inverts the diagnosis: an E401 here says "npm read a config you did not write", not "the secret is expired". Chasing the secret would have replaced a working credential and left the workflow broken. Fixed by dropping `registry-url:`, so this authenticates exactly the way `publish-npm.yml` does — one mechanism for both npm paths, which is what makes the workflow's own premise true: the token that publishes the set is the token that retags it. `publish-npm.yml` was never affected; it uses `setup-bun`, and `bun publish` reads `~/.npmrc`. Also fails on the credential once, up front, instead of fourteen identical per-package errors that look like a registry-side refusal of the operation itself. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTcEKXTQMYt84fAjuw5A2M
1 parent abddef7 commit 2871626

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎.github/workflows/npm-dist-tag.yml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v4
3737

38+
# NO `registry-url:` here. It makes setup-node write its own .npmrc and export
39+
# NPM_CONFIG_USERCONFIG at it, which SHADOWS the ~/.npmrc the step below writes —
40+
# npm then authenticates with setup-node's literal `${NODE_AUTH_TOKEN}` placeholder
41+
# and returns E401 "token seems to be invalid" for every package, which reads as a
42+
# dead secret rather than a shadowed config. Authenticate exactly the way
43+
# publish-npm.yml does, so the token that publishes the set is the token that retags it.
3844
- name: Set up Node
3945
uses: actions/setup-node@v4
4046
with:
4147
node-version: '22'
42-
registry-url: 'https://registry.npmjs.org'
4348

4449
- name: ${{ inputs.action }} '${{ inputs.tag }}' across the lockstep set
4550
env:
@@ -51,6 +56,11 @@ jobs:
5156
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
5257
trap 'rm -f ~/.npmrc' EXIT
5358
59+
# Fail on the credential, once, before touching 14 packages. Without this an
60+
# auth problem arrives as fourteen identical per-package errors and looks like a
61+
# registry-side refusal of the operation.
62+
npm whoami >/dev/null 2>&1 || { echo "::error::NPM_TOKEN does not authenticate"; exit 1; }
63+
5464
node scripts/publish-set.mjs > "${RUNNER_TEMP}/set.txt"
5565
test -s "${RUNNER_TEMP}/set.txt"
5666

0 commit comments

Comments
 (0)