ci: publish via OIDC, so no npm token has to exist - #13
Merged
Conversation
Trusted publishing lets the workflow exchange a short-lived, workflow-scoped
OIDC credential with npm at publish time. Nothing long-lived is stored, so
there is no secret to leak, rotate, or accidentally paste somewhere it becomes
visible.
That last one is not hypothetical: an npm token was created for this repo today
and ended up as a GitHub Actions secret *name* rather than its value — and
names are visible metadata, not secrets. The token has been revoked. This
change removes the reason to ever create another one.
Two things the workflow would have failed on, from the npm docs:
- Node 22 bundles npm 10.x, but trusted publishing requires npm >= 11.5.1.
Node 24 ships npm 11, so the runtime is bumped rather than adding a
separate npm upgrade step.
- `NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}` passed an empty string once the
secret was gone. The documented OIDC example sets no token at all — the
`id-token: write` permission already present is what does the work.
Provenance also stops needing the flag: npm generates attestations
automatically for a public package published from a public repo via OIDC.
Still required on the npm side, and not verified until the first publish
attempt (npm does not validate the config when saved): the trusted publisher
must name this repo and `publish.yml` exactly, and package.json's
repository.url must match the GitHub repo — it does.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trusted publishing lets the workflow exchange a short-lived, workflow-scoped OIDC credential with npm at publish time. Nothing long-lived is stored, so there is no secret to leak, rotate, or accidentally paste somewhere it becomes visible.
That last one isn't hypothetical. A token created for this repo today ended up as a GitHub Actions secret name rather than its value — and names are visible metadata, not secrets. It's been revoked, and the misnamed secret deleted. This change removes the reason to ever create another one.
Two things the workflow would have failed on
Both from the npm docs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}— an empty string once the secret was goneid-token: writepermission already present does the workProvenance also stops needing a flag — npm generates attestations automatically for a public package published from a public repo via OIDC.
What still has to be true on the npm side
The trusted publisher must name this repo and
publish.ymlexactly (case-sensitive, with the extension), andpackage.json'srepository.urlmust match the GitHub repo — it does (git+https://github.com/maonakamoto/ai-forms.git).Worth knowing: npm does not validate the trusted-publisher config when you save it. A typo surfaces only as
ENEEDAUTHon the first publish attempt.🤖 Generated with Claude Code