Skip to content

fix: skip the release job when there's nothing to publish#41

Merged
zanlucathiago merged 1 commit into
mainfrom
fix/skip-release-on-noop
Jul 13, 2026
Merged

fix: skip the release job when there's nothing to publish#41
zanlucathiago merged 1 commit into
mainfrom
fix/skip-release-on-noop

Conversation

@zanlucathiago

Copy link
Copy Markdown
Owner

What's wrong

The Release workflow runs on every push to main. When a commit has no pending changeset — a Dependabot bump, a docs change, any routine merge — changesets/action still runs the publish script, which tries to re-publish the current version. That version is already on npm, so it should no-op, but changesets 2.31.0 crashes parsing npm's "already published" response:

error TypeError: Cannot read properties of undefined (reading 'includes')
    at isAlreadyPublishedError (@changesets/cli/.../changesets-cli.cjs.js:873:17)

The result is a red X on every routine merge — see run #27, triggered by merging the Dependabot PR #39. The next merge (e.g. #40) would fail the same way. The published package itself is fine; 0.4.0 shipped correctly from the #38 release.

The fix

A guard step runs changesets/action only when there's actually something to do — a changeset is pending, or the local package.json version isn't the one published on npm:

- name: Anything to release?
  id: release_needed
  run: |
    pending=$(find .changeset -maxdepth 1 -name '*.md' ! -name 'README.md' | wc -l | tr -d ' ')
    local_version=$(node -p "require('./package.json').version")
    published_version=$(npm view xls-reader version 2>/dev/null || echo none)
    ...

Behavior across the three cases:

Merge Pending changeset? local vs npm Result
Feature PR (has changeset) yes runs → opens/updates the version PR
"Version Packages" PR no differ runs → publishes the bumped version
Dependabot / docs / chore no equal skips (was crashing)

Notes

  • Can't fully exercise a release workflow locally; I validated the YAML parses and dry-ran the guard logic against the current repo state (pending=0, 0.4.0 == 0.4.0 → skip). The real paths only run on merge to main.
  • Infra-only change, no changeset (a workflow tweak shouldn't version the package).
  • The eventual "proper" fix is upgrading @changesets/cli once 3.0.0 is stable and past the cooldown; today only 3.0.0-next.* prereleases carry the fix, so this guard sidesteps the bug in the meantime.

The Release workflow runs on every push to main. On a merge with no pending
changeset (Dependabot, docs, chore), changesets/action still ran `publish`,
which tried to re-publish the current version. Since it's already on npm,
changesets 2.31.0 crashed parsing npm's "already published" response instead of
no-opping — red-X-ing every routine merge (e.g. run #27 from the #39 merge).

Guard the step: only run changesets/action when a changeset is pending or the
local version isn't the one published on npm. Routine merges now skip it; the
real release paths (open the version PR / publish the bumped version) are
unchanged.
@zanlucathiago zanlucathiago merged commit bba7b3f into main Jul 13, 2026
3 checks passed
@zanlucathiago zanlucathiago deleted the fix/skip-release-on-noop branch July 13, 2026 18:05
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.

1 participant