Repository navigation
ci: publish the npm packages from CI by trusted publishing, with provenance - #249
Merged
Merged
Conversation
…enance (#246) publish.yml, run by hand from main in the npm environment, publishes every package whose version npm lacks with pnpm -r publish: in dependency order, one at a time, each after its prepublishOnly. npm takes the run's ID token in place of an access token and records each package's provenance. Node 24, since pnpm publishes through npm and npm takes a trusted publisher's token from 11.5.1.
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…sign (#246) npm's default registry is npm's, and setup-node would write a placeholder token for it that nothing here needs. design/build.md lists the player's prepublishOnly with its first step, the check that the pack it names is on npm.
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.
Closes #246.
Every package is published by hand with a one-time password today, so none has provenance. This adds a workflow that publishes by npm's trusted publishing. It stores no token, needs no one-time password, and npm records each tarball's provenance: the run and the commit it was built from. The workflow mirrors
vscode-publish.yml, which has published the extension to Open VSX this way since 0.1.1.What changes
.github/workflows/publish.yml, run by hand from main in thenpmenvironment, withid-token: write:vscode-publish.yml.pnpm -r --workspace-concurrency=1 publish --access public --no-git-checks. pnpm publishes every package whose version npm lacks, in dependency order and one at a time, and passes over the rest. Each package'sprepublishOnlyruns first, as on a publish by hand, with Chromium installed for the browser tests.NPM_CONFIG_PROVENANCE: true, so a run that cannot record provenance fails instead of publishing without it.dry-runinput packs and checks without publishing. A package that pins another one going out in the same release stops at its own check that the pin is on npm.design/build.md: the publishing section starts with the rule and how the workflow publishes. A publish by hand with a one-time password still works, without provenance.design/commands.md: namesgh workflow run publish.yml.Your part, once, before the first run
The environment: Settings, Environments, a new
npmenvironment whose deployment branches are main only.The publishers: on npmjs.com, for each of the nine packages, Settings, then Trusted publisher, then GitHub Actions, with:
missing-elements;h5p-toolkit;publish.yml;npm.The nine packages: player, runtime, libraries, normalize, verify, embed, cmi5, author, mcp.
Optional, after a release from CI: set each package's publishing access to require two-factor authentication and refuse tokens.
The release flow changes at one step: after the bump is committed and pushed, run the workflow (
gh workflow run publish.yml, or from the Actions tab) instead ofpnpm publish. Runci.ymlby hand first before a player release, as now.Tested
pnpm publishrunsnpm publish <tarball>, and the recursive publish asks the registry first (isAlreadyPublished) and skips a version npm has.git+https://github.com/missing-elements/h5p-toolkit.git, which npm's provenance check compares with the repository the run is in.Summary by cubic
Moves package publishing from hand-run
pnpm publish(one-time password, no provenance) to a CI workflow that uses npm's trusted publishing: no token is stored, and npm records each tarball's provenance. The next release is the workflow's first real run, so it is deliberately not tested end to end before merge.Setup, once
npmenvironment in the repository settings whose deployment branches are main only.publish.ymlworkflow, and thenpmenvironment.gh workflow run publish.ymlfrom main instead ofpnpm publish. It publishes every package whose version npm lacks, in dependency order, one at a time; adry-runinput packs and checks without publishing.NPM_CONFIG_PROVENANCE: trueso a run that cannot record provenance fails instead of publishing without it.registry-urlis set: the workflow targets npm's default registry, and setup-node would write a placeholder token for it. Each package'sprepublishOnlyruns first, as on a publish by hand; the player's begins by checking that the pack it names is on npm.Written for commit 0655856. Summary will update on new commits.