Repository navigation
feat(npm-publish)!: publish with OIDC only - #44
Open
rekmarks-consensys-1 wants to merge 4 commits into
Open
rekmarks-consensys-1 wants to merge 4 commits into
rekmarks-consensys-1 wants to merge 4 commits into
Conversation
OIDC can publish only a package that is already on npm, with its trusted publisher configured. scripts/publish-placeholder.sh publishes an empty 0.0.0 of each given package from a workstation, after checking that it is public and not on npm yet, and deprecates that version. The placeholder is built in a temporary directory, so nothing from the repository runs and its .npmrc files don't apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the `npm-token` input. Packages are published only with OIDC (npm trusted publishing), staged, with provenance for public repositories, and a `YARN_NPM_AUTH_TOKEN` from the caller's job is unset. If any package to publish has never been on npm, the action now fails before publishing or packing anything, in a dry run too, and lists every such package. Its first version is a placeholder published with scripts/publish-placeholder.sh; the README's "New packages" section describes the steps. `dry-run` is now required and must be `true` or `false`: with it unset, a publish job whose OIDC grant was missing used to pack and pass. With `dry-run: false`, a job without OIDC fails before publishing anything. The test fixtures' packages to publish are now on npm, at versions that are not (`@types/node@999.0.0`), and a new fixture has a package that has never been published. BREAKING CHANGE: `npm-token` is removed, `dry-run` is required, and a package that has never been published fails the action. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Run `npm view` in a private directory with its own package.json, not in /tmp. npm loads the .npmrc next to the nearest package.json above its working directory as project configuration, so a package.json and an .npmrc with a proxy in /tmp could answer the lookups. - publish-placeholder.sh: run npm in a directory with its own package.json for the same reason (an .npmrc in /tmp could read the npm token). Only deprecate a package whose only version on npm is 0.0.0, so running the script again finishes a run that stopped partway. Go on past a failing package and list the failures. Say so when there's no answer at the prompt. Reject `~` in new names, as npm does. - README: the action checks only that each package is on npm, not its trusted publisher; describe what happens if that is missing or expired. - Tests: the `registry` fixture's package is on npm, so the job fails if the registry check is removed; the never-published cases run without OIDC, so they fail if the OIDC check comes first; the npm shim fails unless npm view runs in a directory with its own package.json; and test/publish-placeholder.sh tests the placeholder script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pkdiff downloads <name>@latest with `npm pack` in a directory under the system temporary directory, and npm loads the .npmrc next to the nearest package.json above its working directory, so files in /tmp could redirect the dry run's report download. report.sh now runs pkdiff in a new private directory with an empty package.json, which is also its TMPDIR, and the report step no longer sets `working-directory: /tmp`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026
This branch has not been deployed
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.
Lines added, by type
Makes
npm-publishpublish only with OIDC (npm trusted publishing), as upstreamMetaMask/action-npm-publishv8 does (#149, #148, #162), and adds a script that publishes a placeholder version of a new package, so its trusted publisher can be configured before its first release.To review: the first commit adds
scripts/publish-placeholder.shon its own; the second changes the action, its tests and the README.Changes
npm-tokenis removed. Packages are published only with OIDC, staged, with provenance for public repositories.environment.shno longer keepsYARN_NPM_AUTH_TOKEN, so a token set by the caller's job, which interferes with OIDC, is unset.main.shchecks this, in parallel, with a newscripts/never-published.sh, after it finds the packages to publish and before the publish loop, so a release with a new package publishes nothing rather than part of the release. Unlike upstream, a dry run fails too, so the dry-run job reports it before the environment's approval.dry-runis required and must betrueorfalse. With it unset, a publish job whoseid-token: writewas missing used to pack and pass. Withdry-run: false, a job without OIDC now fails inmain.sh, before anything is published.publish.shhas two modes: pack, oryarn npm publish --staged(plus--provenancefor a public repository). The npm lookup and the token path are gone from it.scripts/publish-placeholder.shpublishes<name>@0.0.0for each given package directory, from a maintainer's workstation, logged in to npm:0.0.0(looked up withnpm-view.sh).--access public, a package containing onlypackage.json(name,version, and the workspace'sdescription,licenseandrepository) and a README saying it's a placeholder, then deprecates that version.0.0.0is only deprecated, so running the script again finishes a run that stopped partway. A failing package doesn't stop the others; failures are listed at the end.package.jsonof its own, so nothing from the repository runs and no.npmrcapplies other than the user's and the global one.0.0.0, so the placeholder can't collide with a release.npm viewruns in a private directory with its ownpackage.json, instead of/tmp. npm loads the.npmrcbeside the nearestpackage.jsonabove its working directory as project configuration, so files planted in/tmpcould otherwise answer the lookups. This was already the case before this PR; the PR relies on the lookups more.workflow_call), npm checks the calling workflow's file name, and both workflows needid-token: write.Tests
test/publish-modes.sh:dry-runtrueandfalse, without OIDC (so the check must come before the OIDC check), listing each, in a polyrepo and in a monorepo, with nothing packed or published;npmstand-in fails unlessnpm viewruns in a directory with its ownpackage.json;dry-run: falsewithout OIDC fails before any workspace is published;dry-runfails;YARN_NPM_AUTH_TOKENfrom the job is unset before publishing.yarnstand-in that fails in one package, since a missing OIDC grant fails before the loop.test/environment-variables.shnow expectsYARN_NPM_AUTH_TOKENto be unset.test/publish-placeholder.shtests the placeholder script with annpmstand-in that keeps a fake registry: contents of the placeholder, the refusals, deprecating without re-publishing, and going on past a failure. It also fails unless npm runs in a directory with its ownpackage.json. Themodesjob runs it..github/workflows/test_npm-publish.ymlandtest/make-fixture.sh:@types/node@999.0.0). None of these jobs hasid-token: write, so nothing can be published.newfixture adds a never-published package, and a new job expects it to fail withdry-runtrueandfalse, with nothing packed.rejectedalso covers an emptydry-run, and itsregistryfixture's package is on npm, so it would be packed without the registry check.polyreposetsdry-run: true. The sanitize job's scope-registry override now targets@types.The placeholder script's lookups were run locally against the real registry: a package already on npm and a duplicate are refused. It hasn't been used to publish anything. The new tests were checked by mutation: putting the OIDC check before the never-published check, running
npm viewfrom/tmp, and dropping the placeholder script's ownpackage.jsoneach make tests fail.Breaking changes
npm-tokenis removed; callers must remove it.dry-runis required.🤖 Generated with Claude Code