Skip to content

Commit aa9199f

Browse files
committed
fix(ci): clear setup-node .npmrc to enable OIDC trusted publishing
setup-node with `registry-url` writes `always-auth=true` + `_authToken=${NODE_AUTH_TOKEN}` to the user-level .npmrc, but we don't pass a `token` input. NODE_AUTH_TOKEN is empty at runtime, so npm sends an empty Authorization header on PUT and npmjs responds with `Not Found`. OIDC discovery never engages because npm thinks the registry is already (badly) authenticated. Overwrite the userconfig with just `registry=https://registry.npmjs.org/` so npm sees no static auth for the registry, hits the OIDC path, and exchanges the GitHub Actions id-token for a publish token via the trusted publishers we registered yesterday.
1 parent 01df3ea commit aa9199f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ jobs:
5656
npm install -g npm@^11.10.0
5757
npm --version
5858
59+
- name: Clean setup-node .npmrc for OIDC
60+
# actions/setup-node with `registry-url` writes
61+
# always-auth=true
62+
# //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
63+
# Since we don't pass a `token` to setup-node, NODE_AUTH_TOKEN is
64+
# effectively empty, so npm ends up sending an empty Authorization
65+
# header on PUT and npmjs responds `Not Found`. To make OIDC
66+
# trusted publishing kick in, the registry entry must be present
67+
# without any token line — npm then asks GitHub Actions for an
68+
# id-token and exchanges it for a publish token.
69+
run: |
70+
cat > "$NPM_CONFIG_USERCONFIG" <<'EOF'
71+
registry=https://registry.npmjs.org/
72+
EOF
73+
echo "--- effective userconfig ($NPM_CONFIG_USERCONFIG) ---"
74+
cat "$NPM_CONFIG_USERCONFIG"
75+
5976
- name: Force npm as nx release publish driver (for this job only)
6077
# nx.json keeps `cli.packageManager: bun` globally — bun is the
6178
# monorepo's workspace package manager, handles `workspace:*`

0 commit comments

Comments
 (0)