fix(ci): publish with the npm CLI so OIDC trusted publishing works - #4
Merged
Conversation
The 0.1.0 publish failed with `404 Not Found - PUT` even though the npm
trusted publisher record (ethersphere/core-sdk, publish_npmjs.yml,
environment publish) is correct and provenance signing succeeded.
Cause is in the runner env, visible in the failed run's log:
NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
NODE_AUTH_TOKEN: XXXXX-XXXXX-XXXXX-XXXXX
setup-node's `registry-url` always writes an .npmrc containing
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}. With no token
supplied, NODE_AUTH_TOKEN is that literal placeholder. npm >= 11.5.1
detects that OIDC is available and replaces it with a real
trusted-publishing token; pnpm 10.29.2 sent the placeholder verbatim, and
the registry answers 404 on PUT rather than 401/403 so as not to leak
whether a package exists.
So this was never a permissions problem -- it was an unauthenticated
request wearing a placeholder token.
Switches the publish step to `npm publish` and bumps the job to node 24,
which is what pins npm to 11.x. That is exactly how swarm-cli publishes.
pnpm still handles install and build; only the publish call changes.
Note this is NOT pnpm/pnpm#11513 (OIDC broken in pnpm 11) -- that
regression is in 11.0.8 and this ran 10.29.2.
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.
The
0.1.0publish failed with404 Not Found - PUTeven though the trusted publisher record is correct (ethersphere/core-sdk/publish_npmjs.yml/ environmentpublish) and provenance signing succeeded:Cause
From the failed run's env:
setup-node'sregistry-urlalways writes an.npmrccontaining//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}. With no token supplied,NODE_AUTH_TOKENis that literal placeholder. npm ≥ 11.5.1 detects OIDC is available and overrides the placeholder with a real trusted-publishing token. pnpm 10.29.2 sent the placeholder verbatim, and the registry answers404on PUT rather than401/403so it doesn't leak whether a package exists.So this was never a permissions problem — it was an unauthenticated request wearing a placeholder token, and the
404made it look like the package was missing.For the record this is not pnpm/pnpm#11513 (OIDC broken in pnpm 11) — that regression landed in 11.0.8 and this run used 10.29.2.
Fix
npm publishinstead ofpnpm publish, and node 24 instead of 22 — node 24 is what pins npm to 11.x. This is exactly how swarm-cli publishes, which has five consecutive successful releases on it. pnpm still does install and build; only the publish call changes.After merge
mainis already at0.1.0and thecore-sdk-v0.1.0release exists, but npm only has0.0.1. Thisfix:commit will have release-please open a0.1.1release PR — merging that cuts a release and gives the workflow a genuine end-to-end run. npm will end up with0.0.1and0.1.1, skipping0.1.0, which is a cosmetic gap in exchange for not hand-rolling tags.