Skip to content

Commit 917e90a

Browse files
committed
ci: strip _authToken from .npmrc instead of clearing env vars
Keep setup-node's registry-url config (npm needs to know the registry) but remove the _authToken and always-auth entries from .npmrc so npm falls through to OIDC trusted publishing.
1 parent 3a41092 commit 917e90a

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/release-node.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ jobs:
5555

5656
- name: Publish to npm (trusted publishing)
5757
working-directory: packages/cli
58-
env:
59-
NODE_AUTH_TOKEN: ""
60-
NPM_CONFIG_USERCONFIG: ""
6158
run: |
6259
echo "Node: $(node --version) / npm: $(npm --version)"
60+
# Strip token auth from .npmrc so npm uses OIDC instead
61+
NPMRC="${NPM_CONFIG_USERCONFIG:-$HOME/.npmrc}"
62+
if [ -f "$NPMRC" ]; then
63+
sed -i '/_authToken/d' "$NPMRC"
64+
sed -i '/always-auth/d' "$NPMRC"
65+
echo "Cleaned .npmrc:"
66+
cat "$NPMRC"
67+
fi
6368
npm publish --access public --provenance
6469
6570
- name: Create GitHub Release
@@ -123,11 +128,15 @@ jobs:
123128

124129
- name: Publish to npm (trusted publishing)
125130
working-directory: packages/sdk
126-
env:
127-
NODE_AUTH_TOKEN: ""
128-
NPM_CONFIG_USERCONFIG: ""
129131
run: |
130132
echo "Node: $(node --version) / npm: $(npm --version)"
133+
NPMRC="${NPM_CONFIG_USERCONFIG:-$HOME/.npmrc}"
134+
if [ -f "$NPMRC" ]; then
135+
sed -i '/_authToken/d' "$NPMRC"
136+
sed -i '/always-auth/d' "$NPMRC"
137+
echo "Cleaned .npmrc:"
138+
cat "$NPMRC"
139+
fi
131140
npm publish --access public --provenance
132141
133142
- name: Create GitHub Release

0 commit comments

Comments
 (0)