Skip to content

ci(release): skip already-published versions in the publish script - #217

Merged
thomasfosterau merged 1 commit into
trunkfrom
issue-216-release-output
Oct 3, 2026
Merged

thomasfosterau merged 1 commit into
trunkfrom
issue-216-release-output

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

Summary

Closes #216.

Root cause. The Version or publish job's publish branch runs on every push with no pending changesets, not only on a Version Packages merge. The release script started with a single-package pnpm 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 skipped changeset tag, so the CHANGESETS_OUTPUT file the action passes in was never created. That is why the action reported Publish command exited with code 1 and also warned Failed 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-tag in @changesets/cli 3.0.3 already read CHANGESETS_OUTPUT from the environment (withEnvOptions in dist/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:

Pending changesets Version at the commit Result
≥1 any success: version PR opened or updated
0 new, not yet on npm (Version Packages merges 2bb0e5d, 3e82d56, 9233234, 7f4f213, 48e09fe) success: published, tagged, released
0 already on npm (67ee922 at 0.15.2, d3def7a, ca9677c, acbe684 at 0.16.3) failure: exit 1 plus the CHANGESETS_OUTPUT warning

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.
    • A recursive pnpm publish skips any workspace package whose version the registry already has ("There are no new packages that should be published") and exits 0, the same as changeset publish.
    • The root is a workspace member ("." in pnpm-workspace.yaml) and the three examples are private: true, so the recursive publish covers exactly this package.
    • changeset git-tag is the non-deprecated name for changeset tag, which now logs a deprecation warning. It checks local and remote tags, so an already-tagged version produces no event. It writes one git-tag NDJSON event per new tag to $CHANGESETS_OUTPUT.
  • The release.yml comment and PUBLISHING.md now describe this. The old text said the action parses New tag: stdout, which was v1 behaviour; v2.1.2 reads CHANGESETS_OUTPUT, as readChangesetsOutput / runPublish in src/run.ts at the pinned ae32849 show.

Publish auth (OIDC trusted publishing), provenance and the npm setup are untouched.

Proof without publishing. I simulated the action's runPublish():

  • set CHANGESETS_OUTPUT to a temp .ndjson and pnpm_config_verify_deps_before_run=false, as the job does;
  • ran pnpm run release with a fake pnpm first on the script's PATH, which records its args and appends --dry-run to publish;
  • parsed the file with a copy of the action's readChangesetsOutput.

There were no npm credentials in the environment.

  • A. Current trunk state (0.16.3 already on npm and tagged on the remote; local tag removed, as on the runner): There are no new packages that should be published, then Did 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.
  • B. New version (package.json temporarily set to 0.16.4): 📦 @thomasfosterau/effect-jsonapi@0.16.4 → https://registry.npmjs.org/ (dry run), then Created 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.
  • Contrast: a single-package pnpm publish --dry-run at 0.16.3 prints Skip 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):

  1. The release environment's deployment-branch rule still excludes trunk. The first Release run on trunk after 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 needs trunk, as PUBLISHING.md's maintainer setup step 3 says. Until that changes, no Release run on trunk can show this fix in CI.
  2. npm trusted publisher. Check that the npmjs.com trusted-publisher entry (workflow release.yml, environment release) 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 admits trunk. 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.
  3. Provenance stays off while the repository is private (unchanged).

Verification

Run in order on a fresh clone, one at a time, with --no-cache:

  • pnpm install --frozen-lockfile: pass
  • vp run build: pass
  • vp 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 hits
  • vp run -r test:unit: pass (1931 + 38 + 41 + 51 tests)
  • vp run docgen (every JSDoc @example compiled and executed): pass
  • fallow audit --base origin/trunk (--format json --quiet --explain --gate-marker agent): verdict pass
  • pnpm audit --audit-level high: no known vulnerabilities

A real Release run can't run from a PR. It needs the merge to trunk and owner item 1.

Changeset

None: this changes only CI and release tooling, and the published package is unaffected.

  • A changeset under .changeset/ for every change to published behaviour (n/a)

Notes

  • --recursive would also publish any future non-private workspace package. Today that is only the root, because the examples are private.
  • After a Version Packages merge, the first Release run publishes and tags as before. Every later push without changesets is now a green no-op instead of a red run.

🤖 Generated with Claude Code


Generated by Claude Code

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>
@thomasfosterau
thomasfosterau merged commit 91c9599 into trunk Oct 3, 2026
1 check passed
@thomasfosterau
thomasfosterau deleted the issue-216-release-output branch October 3, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release: publish step fails reading Changesets output (CHANGESETS_OUTPUT)

2 participants