chore(cd): publish through the npm CLI so provenance works - #534
Merged
Conversation
The release workflow has never completed a publish since #526 moved it off tokens. Four separate problems, none of which had run yet: - `npm install -g npm@latest` now resolves to npm 12, which requires Node >=22.22.2 while the workflow pins Node 20. Pinned to npm 11, the newest line that runs on Node 20 and still supports provenance and OIDC. - `lerna publish --provenance` fails outright. Lerna 4's CLI is yargs `.strict()` and does not declare that option, so it exits with "Unknown argument: provenance". - Lerna 4 uploads through `libnpmpublish@4`, which supports neither provenance nor OIDC trusted publishing, so no npm CLI upgrade can make `lerna publish` work. The release is now split: `lerna version` still handles bumps, changelogs, tags and the GitHub release, and `scripts/publish-packages.sh` does the upload with `npm publish --provenance`. - `permissions: contents: read` cannot push the release commit or tags, or create the GitHub release. Before #526 there was no permissions block, so the default write access applied. The publish script skips any package whose version is already on the registry, since lerna versions these independently and a release may bump only one of them.
2 tasks
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.
Fixes the release pipeline so it can publish
13.0.0. Targetsstabledirectly because CD reads the workflow from the pushed commit, so the fix has to be on the release branch to take effect.What is the current behavior?
Currently the release workflow cannot publish. Run 32296237958 failed on the
Ensure Latest npmstep, and there are three more failures queued up behind it. None of this had run before, because #526 moved the workflow off tokens after the last release, so12.3.0was published by the older token-based workflow.npm install -g npm@latestresolves to npm 12.0.2, which requiresnode ^22.22.2 || ^24.15.0 || >=26.0.0. The workflow pins Node 20, so the install fails withEBADENGINE.lerna publish --provenancecannot work. Lerna 4's CLI is yargs.strict()andpublishdoes not declare aprovenanceoption, so it exits withUnknown argument: provenance.libnpmpublish@4.0.2, which has no provenance support and no OIDC support. Since it never shells out tonpm publish, upgrading the global npm does nothing for the upload, and trusted publishing is unreachable fromlerna publishat this version.permissions: contents: readcannot push the release commit or tags, or create the GitHub release. Before chore(npm): Update release npm action to stop using tokens #526 there was nopermissionsblock, so the default write access applied.What is the new behavior?
The release is split in two. Versioning stays with lerna, so bumps, changelogs, tags, and the GitHub release all work exactly as before. The upload moves to the npm CLI, which is what actually supports provenance and OIDC trusted publishing.
version:cirunslerna version, keeping thelerna.jsonconfig (allowBranch,conventionalCommits,createRelease, the[skip ci]message,tagVersionPrefix).publish:cirunsscripts/publish-packages.sh, which publishes each package withnpm publish --provenance.npm@11, the newest line that runs on Node 20 and still supports provenance and OIDC. This keeps CD on the same Node version as CI.contentsis nowwrite.The publish script skips any package whose version is already on the registry, because these version independently and a release may bump only one of them.
Does this introduce a breaking change?
No package code changes. This commit touches only
.github/workflows/cd.yml, the rootpackage.json, and a new script, so lerna attributes it to neither package and it does not affect the computed versions.Other information
I verified locally that both packages still compute a major from the v9 squash on
stable(0883d9b), which carries theBREAKING CHANGE:footer:lerna changedlists both packages, andnpm run version:ciparses its flags and loads thelerna.jsonconfig cleanly, failing only on the missingGH_TOKENthat CI supplies. The publish script's skip logic was tested against both the already-published case and a simulated13.0.0.Note: I could not verify the OIDC handshake itself without running a real publish, so that part is unproven. It also depends on trusted publishing being configured on npmjs.com for both
@ionic/angular-toolkitand@ionic/cordova-builders. If either is missing, the publish step will fail on auth, and the fix is to add the trusted publisher for that package rather than to change the workflow again.Merging this triggers CD, which will cut the release.