Skip to content

ci: publish via OIDC, so no npm token has to exist - #13

Merged
github-actions[bot] merged 1 commit into
mainfrom
ci/trusted-publishing
Aug 16, 2026
Merged

ci: publish via OIDC, so no npm token has to exist#13
github-actions[bot] merged 1 commit into
mainfrom
ci/trusted-publishing

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

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:

was now
npm version Node 22 → bundles npm 10.x; OIDC needs >= 11.5.1 Node 24, which ships npm 11
auth NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} — an empty string once the secret was gone no token at all; the id-token: write permission already present does the work

Provenance 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.yml exactly (case-sensitive, with the extension), and package.json's repository.url must 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 ENEEDAUTH on the first publish attempt.

🤖 Generated with Claude Code

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>
@github-actions
github-actions Bot merged commit 957462f into main Aug 16, 2026
1 check passed
@github-actions
github-actions Bot deleted the ci/trusted-publishing branch August 16, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant