Skip to content

Commit ced5cc3

Browse files
author
strausr
committed
fix: override NPM_CONFIG_USERCONFIG in publish step for OIDC-only
Point npm at a minimal .npmrc so it ignores setup-node's config and uses OIDC only.
1 parent 56f51c8 commit ced5cc3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,18 @@ jobs:
141141
# npm publish uses OIDC (id-token: write + --provenance). No NPM_TOKEN needed.
142142
# Require on npmjs.com: Package → Package settings → Trusted publishers →
143143
# Add: GitHub Actions, org cloudinary-devs, repo create-cloudinary-react, workflow release.yml
144-
# Unset token env vars so npm uses OIDC only; stale NPM_TOKEN/NODE_AUTH_TOKEN causes "Access token expired".
144+
# Force OIDC-only: override NPM_CONFIG_USERCONFIG so npm ignores setup-node's .npmrc (which may reference a stale token).
145145
- name: Publish to npm using trusted publishing
146146
if: github.event.inputs.dry_run != 'true'
147147
env:
148148
NODE_AUTH_TOKEN: ''
149149
NPM_TOKEN: ''
150+
NPM_CONFIG_USERCONFIG: '${{ runner.temp }}/.npmrc-oidc'
150151
run: |
151152
echo "=== Publishing to npm with trusted publishing (OIDC) ==="
152153
unset NODE_AUTH_TOKEN NPM_TOKEN 2>/dev/null || true
153-
# Use minimal .npmrc so npm uses OIDC, not a stale token from setup-node
154-
echo "registry=https://registry.npmjs.org/" > ~/.npmrc
154+
# Config that has only registry — no _authToken — so npm uses OIDC
155+
echo "registry=https://registry.npmjs.org/" > "$NPM_CONFIG_USERCONFIG"
155156
156157
# Get versions
157158
VERSION_BEFORE="${{ steps.version-before.outputs.version }}"

0 commit comments

Comments
 (0)