Skip to content

ci: publish via npm trusted publishing (OIDC), no stored token - #5

Merged
kaufmanhenry merged 1 commit into
mainfrom
ci/trusted-publishing
Sep 29, 2026
Merged

kaufmanhenry merged 1 commit into
mainfrom
ci/trusted-publishing

Conversation

@kaufmanhenry

Copy link
Copy Markdown
Owner

Publishing moves from a stored npm token to trusted publishing over OIDC.

Why

The automation token in ~/.npmrc had expired, which is why 2.1.0 nearly didn't ship — and why 2.0.4 was merged but never published at all. Granular tokens are the only kind npm issues now and every one carries a mandatory expiry, so that failure repeats on a timer.

npm is also removing direct publishing with bypass-2FA tokens in January 2027, so the token path is a dead end either way.

With OIDC there is no stored credential: npm trusts .github/workflows/publish.yml in this repo, and each publish mints a short-lived one.

How releases work now

npm version <patch|minor|major> --no-git-tag-version
# CHANGELOG, commit, merge to main, then:
git tag -a vX.Y.Z -m vX.Y.Z && git push origin vX.Y.Z

Pushing the tag is the release.

Guards in the workflow:

  • refuses to publish if the tag and package.json version disagree
  • runs the suite on macos-latest, matching ci.yml — the package is macOS-only and a release is the wrong place to discover it doesn't pass on Linux
  • no dependency cache, so the published artifact comes from a clean install
  • pins npm to latest, because OIDC support landed in npm 11.5.x and the runner image shouldn't be able to regress it silently

Provenance attestations are generated automatically (public repo, public package) — no --provenance flag required.

Not done here: the npmjs.com side

This PR is inert until a trusted publisher is configured on npmjs.com. That requires an interactive 2FA challenge and can't be scripted. Settings → Trusted Publisher → GitHub Actions:

Field Value
Organization or user kaufmanhenry
Repository thingsctl
Workflow filename publish.yml
Allowed actions must include direct npm publish

Two things that silently break it later: renaming publish.yml (npm pins the filename; fails ENEEDAUTH), and changing repository.url in package.json (must match this repo exactly). Both are called out in the README.

Once a release succeeds this way, the remaining hardening is Settings → Publishing access → "Require two-factor authentication and disallow tokens", then revoking the token created today.

https://claude.ai/code/session_01LMbjcZogpv9EbVnqovXpSX

Replaces token-based publishing. npm trusts this workflow file in this repo
over OIDC, so each publish uses a short-lived credential and there is no
long-lived token stored anywhere.

The immediate reason: the automation token in ~/.npmrc had expired, which is
why 2.1.0 nearly did not ship and why 2.0.4 was merged but never released at
all. Granular tokens are the only kind npm issues now and they all carry a
mandatory expiry, so that failure recurs on a timer. npm is also removing
direct publishing with bypass-2FA tokens in January 2027, which makes the token
path a dead end regardless.

Releases now trigger on a v* tag. The workflow refuses to publish when the tag
and package.json version disagree, runs the suite on macos-latest to match
ci.yml, skips the dependency cache so the published artifact comes from a clean
install, and pins npm to latest because OIDC support landed in npm 11.5.x.

Provenance attestations are generated automatically for a public repo
publishing a public package; no --provenance flag needed.

Requires a one-time trusted-publisher configuration on npmjs.com, which needs
an interactive 2FA challenge and so cannot be scripted.

Claude-Session: https://claude.ai/code/session_01LMbjcZogpv9EbVnqovXpSX
@kaufmanhenry
kaufmanhenry merged commit d9d24bf into main Sep 29, 2026
3 checks passed
@kaufmanhenry
kaufmanhenry deleted the ci/trusted-publishing branch September 29, 2026 17:30
kaufmanhenry added a commit that referenced this pull request Sep 29, 2026
No code changes. Cuts a release so the OIDC pipeline added in #5 is actually
exercised, and so the package gets its first provenance attestation — 2.1.0 was
published from a laptop with a token and carries none.

Proving it now, while today's token still works as a fallback, rather than
discovering a misconfiguration on some future release. npm does not validate a
trusted-publisher config when you save it; the first publish is the only test.

Claude-Session: https://claude.ai/code/session_01LMbjcZogpv9EbVnqovXpSX
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