Skip to content

Commit 44be6e3

Browse files
committed
feat(release): use OIDC trusted publishing for npm publish
1 parent 9477626 commit 44be6e3

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ jobs:
6969
- name: Format check
7070
run: bun run format:check
7171

72-
# Fail fast on bad/missing NPM_TOKEN before any side effects
73-
# (version.ts writes to package.json, network calls to GH, etc.)
74-
# Surfaces auth issues in ~2s instead of mid-publish.
72+
# npm whoami does NOT support OIDC trusted publishing — it only
73+
# works with a static token. We keep NODE_AUTH_TOKEN here so this
74+
# pre-publish sanity check still works. The actual publish step
75+
# authenticates via OIDC (no token needed).
7576
- name: Verify npm auth
7677
run: npm whoami --registry=https://registry.npmjs.org/
7778
env:
@@ -107,11 +108,15 @@ jobs:
107108
# recovery handler prints the exact manual recovery commands.
108109
# ============================================================
109110

111+
# Authentication for npm publish uses OIDC trusted publishing —
112+
# no NODE_AUTH_TOKEN needed. npm CLI auto-detects the OIDC
113+
# environment when id-token: write is set and no token is present.
114+
# Configured on npmjs.com under package settings → Trusted Publishers.
115+
# Requires npm CLI v11.5.1+ and Node 22.14.0+.
110116
- name: Publish to npm
111117
id: publish
112118
run: bun script/publish.ts
113119
env:
114-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
115120
NPM_CONFIG_PROVENANCE: "true"
116121
KILO_CHANNEL: ${{ steps.version.outputs.channel }}
117122

@@ -155,6 +160,9 @@ jobs:
155160
#
156161
# Like the verify step above, this is INFORMATIONAL only —
157162
# it never fails the workflow and never blocks tag/release.
163+
# npm dist-tag add is a write operation NOT covered by OIDC
164+
# trusted publishing (OIDC only covers npm publish). Still
165+
# needs the static token.
158166
- name: Reconcile latest dist-tag (dev publishes)
159167
if: steps.publish.outcome == 'success' && steps.version.outputs.channel == 'dev'
160168
env:

0 commit comments

Comments
 (0)