Skip to content

Commit d93bd99

Browse files
feat(ci): use npm OIDC publishing instead of NPM_TOKEN
- Add id-token: write permission for OIDC provenance - Remove NPM_TOKEN secret dependency (more secure) - Add npm upgrade step for OIDC support - Add OIDC preflight to scrub existing auth tokens - Publish with --provenance --access public flags
1 parent 1eda8b3 commit d93bd99

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
permissions:
99
contents: write
1010
packages: write
11+
id-token: write # Required for npm OIDC provenance
1112

1213
env:
1314
REGISTRY: ghcr.io
@@ -125,9 +126,12 @@ jobs:
125126
retention-days: 1
126127

127128
publish-npm:
128-
name: Publish to npm
129+
name: Publish to npm (OIDC)
129130
needs: assemble-npm
130131
runs-on: ubuntu-latest
132+
permissions:
133+
contents: read
134+
id-token: write # Required for npm OIDC publishing (no NPM_TOKEN needed)
131135
steps:
132136
- uses: actions/checkout@v4
133137

@@ -137,28 +141,44 @@ jobs:
137141
node-version: '20'
138142
registry-url: 'https://registry.npmjs.org'
139143

144+
- name: Upgrade npm for OIDC support
145+
run: npm install -g npm@latest
146+
140147
- name: Download npm packages
141148
uses: actions/download-artifact@v4
142149
with:
143150
name: npm-packages
144151
path: packages/
145152

146-
- name: Publish platform packages
153+
- name: OIDC preflight - ensure no auth tokens
154+
run: |
155+
echo "=== OIDC Preflight ==="
156+
# Remove any existing auth tokens to ensure OIDC is used
157+
for npmrc in "$NPM_CONFIG_USERCONFIG" ~/.npmrc .npmrc; do
158+
if [ -n "$npmrc" ] && [ -f "$npmrc" ]; then
159+
echo "Cleaning $npmrc of any existing auth tokens..."
160+
sed -i -E '/\/\/registry\.npmjs\.org\/:(_authToken|_auth)\s*=/d' "$npmrc" 2>/dev/null || true
161+
sed -i -E '/^\s*(_authToken|_auth)\s*=/d' "$npmrc" 2>/dev/null || true
162+
fi
163+
done
164+
165+
echo "Verifying npm registry connectivity..."
166+
npm ping || exit 1
167+
echo "Registry: $(npm config get registry)"
168+
169+
- name: Publish platform packages with OIDC
147170
run: |
148171
for pkg in packages/ansilust-*/; do
149172
if [ -f "$pkg/package.json" ]; then
173+
echo "Publishing $pkg..."
150174
cd "$pkg"
151-
npm publish
175+
npm publish --provenance --access public
152176
cd - > /dev/null
153177
fi
154178
done
155-
env:
156-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
157179
158-
- name: Publish meta package
159-
run: npm publish packages/ansilust/
160-
env:
161-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
180+
- name: Publish meta package with OIDC
181+
run: npm publish packages/ansilust/ --provenance --access public
162182

163183
create-release:
164184
name: Create GitHub release

0 commit comments

Comments
 (0)