Skip to content

Commit 9b219cb

Browse files
committed
fix(ci): scrub npm token before trusted publish
1 parent 90db73c commit 9b219cb

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ jobs:
8888
8989
- name: Publish to npm
9090
if: ${{ steps.release.outputs.release_created == 'true' && steps.npm_version.outputs.published != 'true' }}
91-
run: npm publish --access public "${{ steps.pack.outputs.tarball }}"
91+
run: |
92+
unset NODE_AUTH_TOKEN
93+
npm publish --access public "${{ steps.pack.outputs.tarball }}"
9294
9395
- name: Attach package tarball to GitHub Release
9496
if: ${{ steps.release.outputs.release_created == 'true' }}
@@ -153,7 +155,9 @@ jobs:
153155
154156
- name: Publish to npm
155157
if: ${{ steps.npm_version.outputs.published != 'true' }}
156-
run: npm publish --access public "${{ steps.pack.outputs.tarball }}"
158+
run: |
159+
unset NODE_AUTH_TOKEN
160+
npm publish --access public "${{ steps.pack.outputs.tarball }}"
157161
158162
- name: Ensure GitHub Release exists
159163
env:

docs/ci-and-release.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ Keep the package public through `publishConfig.access: "public"` and the workflo
151151
npm publish --access public
152152
```
153153

154-
The publish steps intentionally do not define `NODE_AUTH_TOKEN`; npm Trusted
155-
Publishing should use the GitHub OIDC identity directly. Keep `package.json`
156-
`repository.url` exactly aligned with `https://github.com/async-framework/async-db`,
157-
because npm validates trusted publishing against the GitHub repository identity.
154+
The publish steps intentionally unset any inherited `NODE_AUTH_TOKEN`; npm
155+
Trusted Publishing should use the GitHub OIDC identity directly. Keep
156+
`package.json` `repository.url` exactly aligned with
157+
`https://github.com/async-framework/async-db`, because npm validates trusted
158+
publishing against the GitHub repository identity.
158159

159160
If Trusted Publishing is not configured yet, the release workflow can create the release PR and GitHub release, but npm publish will fail until npm trusts this repository and workflow.
160161

test/package/exports.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ test('release automation creates release PRs and publishes npm from pinned actio
373373
assert.match(workflow, /actions\/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6\.0\.2/);
374374
assert.match(workflow, /actions\/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6/);
375375
assert.match(workflow, /id-token: write/);
376-
assert.doesNotMatch(workflow, /NODE_AUTH_TOKEN/);
376+
assert.match(workflow, /unset NODE_AUTH_TOKEN/);
377+
assert.doesNotMatch(workflow, /NODE_AUTH_TOKEN:/);
377378
assert.match(workflow, /npm publish --access public/);
378379
assert.match(workflow, /npm run release:check/);
379380
assert.deepEqual(releaseConfig.packages['.'], {

0 commit comments

Comments
 (0)