Repository navigation
ci(release): skip already-published versions in the publish script - #217
Merged
Merged
Conversation
Every push to trunk with no pending changesets runs the Changesets action's publish branch. The release script ran a single-package `pnpm publish`, which tries to publish over a version npm already has and exits 1; `&&` then skipped `changeset tag`, so the action found no CHANGESETS_OUTPUT file and warned. Every such run since 0.15.2 failed this way, while each Version Packages merge (a new version) passed. `pnpm publish --recursive` skips workspace packages whose version is already on the registry and exits 0, as `changeset publish` does; the root is a workspace member and the examples are private, so it covers exactly this package. `changeset git-tag` (the non-deprecated name of `tag`) reads CHANGESETS_OUTPUT from the environment and writes one git-tag event per new tag, which the action reads to push tags and create releases. Publish auth, provenance and the npm setup are unchanged. Closes #216 Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Closes #216.
Root cause. The
Version or publishjob's publish branch runs on every push with no pending changesets, not only on a Version Packages merge. Thereleasescript started with a single-packagepnpm publish, which does not check the registry first. When the current version is already on npm, it tries to publish over it and exits 1.&&then skippedchangeset tag, so theCHANGESETS_OUTPUTfile the action passes in was never created. That is why the action reportedPublish command exited with code 1and also warnedFailed to read changesets output … Ensure the custom publish script passes CHANGESETS_OUTPUT. The warning follows from the failed publish; it is not a separate wiring fault.changeset tag/git-tagin@changesets/cli3.0.3 already readCHANGESETS_OUTPUTfrom the environment (withEnvOptionsindist/index.mjs), and on every successful publish run the action got the tag and created the release (0.16.0 to 0.16.3 all have releases).The evidence is in the run history. The job logs can't be downloaded from this environment because the log blob host is blocked, but the step results and annotations can be read. Here is each Release run on
main, matched with the pending changesets and the version at its commit:The 0.15.0-era failure on 096c99b fits the same pattern.
Fix (only the repo's own script wiring):
release:pnpm publish --recursive --access public --no-git-checks --ignore-scripts && changeset git-tag.pnpm publishskips any workspace package whose version the registry already has ("There are no new packages that should be published") and exits 0, the same aschangeset publish."."inpnpm-workspace.yaml) and the three examples areprivate: true, so the recursive publish covers exactly this package.changeset git-tagis the non-deprecated name forchangeset tag, which now logs a deprecation warning. It checks local and remote tags, so an already-tagged version produces no event. It writes onegit-tagNDJSON event per new tag to$CHANGESETS_OUTPUT.release.ymlcomment andPUBLISHING.mdnow describe this. The old text said the action parsesNew tag:stdout, which was v1 behaviour; v2.1.2 readsCHANGESETS_OUTPUT, asreadChangesetsOutput/runPublishinsrc/run.tsat the pinnedae32849show.Publish auth (OIDC trusted publishing), provenance and the npm setup are untouched.
Proof without publishing. I simulated the action's
runPublish():CHANGESETS_OUTPUTto a temp.ndjsonandpnpm_config_verify_deps_before_run=false, as the job does;pnpm run releasewith a fakepnpmfirst on the script's PATH, which records its args and appends--dry-runtopublish;readChangesetsOutput.There were no npm credentials in the environment.
There are no new packages that should be published, thenDid not find any packages that need to be tagged.The script exits 0 and the action reads 0 events, with no warning. Before this change, this case exited 1.📦 @thomasfosterau/effect-jsonapi@0.16.4 → https://registry.npmjs.org/(dry run), thenCreated git tags: @thomasfosterau/effect-jsonapi@0.16.4. The script exits 0 and the action reads[{"type":"git-tag","tag":"@thomasfosterau/effect-jsonapi@0.16.4","packageName":"@thomasfosterau/effect-jsonapi"}], which is what it uses to push the tag and create the release. I deleted the local tag and reverted the version afterwards.pnpm publish --dry-runat 0.16.3 printsSkip publishing …@0.16.3 (dry run), meaning it would attempt the publish. The recursive form doesn't.Owner-only items (not changed here; see website#2097):
releaseenvironment's deployment-branch rule still excludestrunk. The first Release run ontrunkafter ci: trigger CI and Release on trunk #215 (37103185057, 8766164) failed before any step ran:Branch "trunk" is not allowed to deploy to release due to environment protection rules.Settings → Environments →release→ deployment branches needstrunk, as PUBLISHING.md's maintainer setup step 3 says. Until that changes, no Release run ontrunkcan show this fix in CI.release.yml, environmentrelease) still matches after the branch rename. The publish step here doesn't change, but it's the next thing that could fail once the environment admitstrunk. I couldn't tell from here whether any of the failed runs also hit an auth error, because the job logs couldn't be downloaded.Verification
Run in order on a fresh clone, one at a time, with
--no-cache:pnpm install --frozen-lockfile: passvp run build: passvp check: pass (0 errors; existing warn-tier debt only)vp run check(sources, type-level tests, examples, emitted declarations): pass, "every type gate green", 0/7 cache hitsvp run -r test:unit: pass (1931 + 38 + 41 + 51 tests)vp run docgen(every JSDoc@examplecompiled and executed): passfallow audit --base origin/trunk(--format json --quiet --explain --gate-marker agent): verdictpasspnpm audit --audit-level high: no known vulnerabilitiesA real Release run can't run from a PR. It needs the merge to
trunkand owner item 1.Changeset
None: this changes only CI and release tooling, and the published package is unaffected.
.changeset/for every change to published behaviour (n/a)Notes
--recursivewould also publish any future non-private workspace package. Today that is only the root, because the examples are private.🤖 Generated with Claude Code
Generated by Claude Code