Skip to content

ci: publish to npm via OIDC trusted publishing#124

Merged
PAMulligan merged 3 commits into
mainfrom
chore/npm-trusted-publishing
Jun 16, 2026
Merged

ci: publish to npm via OIDC trusted publishing#124
PAMulligan merged 3 commits into
mainfrom
chore/npm-trusted-publishing

Conversation

@PAMulligan

Copy link
Copy Markdown
Contributor

What

Switches the manual publish-npm.yml workflow from a long-lived NPM_TOKEN
secret to npm Trusted Publishing (OIDC).

  • Remove NODE_AUTH_TOKEN from the publish step so npm authenticates via the
    GitHub Actions OIDC token against the trusted publisher configured on the
    package at npmjs.com — no stored secret.
  • Add an npm install -g npm@latest step: trusted publishing needs npm
    ≥ 11.5.1 and Node 20 ships npm 10.x.
  • Keep registry-url in setup-node (required — it points npm at the
    registry to mint the OIDC token against; the placeholder _authToken it
    writes is ignored by npm in favour of OIDC when a matching trusted publisher
    exists).
  • Update the header comment to document the new auth model.

Why

The token-based publish was failing with E404 on PUT .../claudius-chat-widget.
The token, account, and permissions all checked out (pmds, read+write all
packages), so the long-lived-secret path was both fragile and the source of the
failure. Trusted Publishing removes the secret entirely and is npm's
recommended path for CI.

Status

The workflow change is complete and the OIDC path is wired correctly (verified
by the error progressing from E404ENEEDAUTH → OIDC engaged once
registry-url was restored). A successful publish additionally requires the
npm Trusted Publisher config to match this repo exactly (case-sensitive):
PMDevSolutions / Claudius / publish-npm.yml, with npm publish allowed.
That match is being verified before the first green run.

Related to #41.

🤖 Generated with Claude Code

Paul Mulligan and others added 3 commits June 15, 2026 19:10
Switch the manual npm publish workflow from a long-lived NPM_TOKEN secret
to npm Trusted Publishing:

- Remove NODE_AUTH_TOKEN from the publish step so npm authenticates via the
  GitHub Actions OIDC token (id-token: write is already granted) against the
  trusted publisher configured on each package at npmjs.com.
- Upgrade the runner's npm to latest before publishing; Trusted Publishing
  needs npm >= 11.5.1 and Node 20 ships npm 10.x.
- Update the header comment to document the new auth model.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
actions/setup-node with registry-url writes an .npmrc containing a placeholder
_authToken (XXXXX-XXXXX-XXXXX-XXXXX). npm sees a configured token and attempts
token auth with that garbage value instead of performing the OIDC
trusted-publishing exchange, producing a 404 on publish. Removing registry-url
leaves no auth token configured, so npm falls through to OIDC. The default
registry is already registry.npmjs.org.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reverts the registry-url removal. The npm docs confirm registry-url is
required for trusted publishing: it points npm at the registry to mint the
OIDC token against. Without it npm performs no OIDC exchange and fails with
ENEEDAUTH. The placeholder _authToken setup-node writes is ignored by npm in
favour of OIDC whenever a matching trusted publisher exists for the package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PAMulligan PAMulligan self-assigned this Jun 16, 2026
@PAMulligan PAMulligan moved this from Todo to Done in PMDS Open Source Roadmap Jun 16, 2026
@PAMulligan
PAMulligan merged commit ebf543b into main Jun 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant