Skip to content

Commit d06c324

Browse files
author
strausr
committed
fix: use OIDC-only for npm publish step
Clear NODE_AUTH_TOKEN/NPM_TOKEN and use minimal .npmrc so npm uses trusted publishing (OIDC) only; avoids 'Access token expired' from stale token.
1 parent a0fbbdd commit d06c324

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,20 @@ jobs:
138138
npx semantic-release
139139
fi
140140
141+
# npm publish uses OIDC (id-token: write + --provenance). No NPM_TOKEN needed.
142+
# Require on npmjs.com: Package → Package settings → Trusted publishers →
143+
# 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".
141145
- name: Publish to npm using trusted publishing
142146
if: github.event.inputs.dry_run != 'true'
147+
env:
148+
NODE_AUTH_TOKEN: ''
149+
NPM_TOKEN: ''
143150
run: |
144151
echo "=== Publishing to npm with trusted publishing (OIDC) ==="
145-
146-
# Ensure .npmrc is available (setup-node should have created it)
147-
if [ -f "$NPM_CONFIG_USERCONFIG" ]; then
148-
cp "$NPM_CONFIG_USERCONFIG" ~/.npmrc
149-
echo "✓ Using .npmrc for authentication"
150-
fi
152+
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
151155
152156
# Get versions
153157
VERSION_BEFORE="${{ steps.version-before.outputs.version }}"

0 commit comments

Comments
 (0)