Publish by OIDC trusted publishing instead of the expired npm token

Merged
UN
3mo ago
+1836-97

The publish credential is dead, and nothing said so

pm-jira last reached npm on 2026.8.17. main reads 2026.8.26, with no matching tag and nothing on the registry. Sixteen of the eighteen published fleet packages are in the same state, all stopping on 2026-08-16 or 2026-08-17.

The release job fails at Publish npm package:

npm error code E404
npm error 404 Not Found - PUT https://registry.npmjs.org/pm-jira - Not found

A 404 on PUT is a rejected write credential, not a missing package. The registry answers 404 rather than 401 so it does not disclose package existence to an unauthorised caller — which is why this reads like a normal first publish rather than an outage. The repository secret was already rotated on 2026-08-22 and the failures continued unchanged; npm whoami against the maintainer host's stored auth returns 401. The credential is dead, not mis-stored.

Nothing else noticed, because the version bump and the release commit both land before the publish step — deliberately, so an interrupted release resumes the same version. So main advances whether or not the artifact ships and every other job stays green.

The change

Trusted publishing removes the credential that can expire: the registry mints a short-lived one from the workflow's own OIDC identity. Two changes had to go together, and the second is the easy one to miss:

  1. NODE_AUTH_TOKEN / secrets.NPM_TOKEN are gone from the publish step. id-token: write and registry-url stay — they are what make OIDC reachable.
  2. npm is raised to >=11.5.1 before the publish step. node 22 ships npm 10.x, which has no trusted-publishing support and would silently fall back to token auth — producing exactly the same E404 and looking like the migration simply failed.

Verification

Two guards fail closed, and both were mutation-checked rather than assumed:

MutationResult
Reintroduce NODE_AUTH_TOKENOIDC test fails
Delete the npm upgrade stepnpm-version test fails
Unmodifiedboth pass

Gates: build, check, test, docstring, changelog:full + changelog:check, and pm health --strict-exit against the pinned binary — all green.

Requires a one-time npmjs.com setup binding pm-jira to unbraind/pm-jira and release.yml before the next release can publish. Until that exists this workflow fails closed, which is correct but is not a release.

pm item


Summary by cubic

Switches npm publishing from the expired stored token to OIDC trusted publishing, and fails the release before any bump or commit when the registry refuses the workflow's identity, so main no longer advances with nothing shipping.

Bug Fixes

  • The release job is gated to main, and npm is re-verified at publish time to ensure it can exchange an OIDC token.
  • The preflight encodes the package name, accepts any 2xx, uses --max-time, and distinguishes registry outages and rate limiting from identity refusals.
  • The preflight's short-lived credential is removed via an EXIT trap; the scrub removes all six legacy credential mechanisms, and the guard joins backslash continuations before splitting commands.
  • Run scripts receive values via env: rather than interpolation, and the interpolation guard scans folded run: blocks in either indicator order.
  • The identity audit refuses new commits with unapproved identities or absolute home paths, requires the baseline be an ancestor of the trusted base ref, and lets maintainers update controls without the gate refusing the change.
  • The changelog-date verifier is now TypeScript, handles continuations, arrays, and shell separators split with or without surrounding whitespace, strips unquoted trailing comments from invocations, asserts the date flag changes the generated heading, and runs in release:check and CI.
  • Release-workflow tests run an enumerated mutation set, all failing on the unmodified workflow.
  • .agents/pm/transactions/ journals are gitignored.

Migration

  • Requires a one-time npmjs.com setup binding pm-jira to unbraind/pm-jira and release.yml, or the preflight fails the run.

Summary by Sourcery

Migrate npm releases to fail-closed OIDC trusted publishing while hardening release validation and workflow security.

Bug Fixes:

  • Replace the expired npm token publishing flow with OIDC trusted publishing and fail releases before version changes when npm rejects the workflow identity.
  • Prevent release workflows from running on non-main refs and harden credential cleanup, runtime npm verification, registry preflight diagnostics, and command interpolation safety.
  • Add controls for approved Git identities and commit history hygiene.

Enhancements:

  • Add release-time verification that changelog dates are derived from package versions across all generator invocations.
  • Improve release workflow safety and idempotence through trusted identity checks, bounded registry requests, short-lived credential cleanup, and environment-based script inputs.

CI:

  • Run changelog-date verification in CI and release checks.
  • Add mutation-focused tests for the release workflow, identity auditing, and changelog-date verification.

Tests:

  • Add comprehensive tests covering OIDC publishing safeguards, npm version enforcement, credential removal, release ordering, identity controls, and changelog-date validation.

Chores:

  • Ignore PM transaction journals and add release audit control files.