fix: skip the release job when there's nothing to publish#41
Merged
Conversation
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.
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.
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/actionstill runs thepublishscript, 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: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.0shipped correctly from the #38 release.The fix
A guard step runs
changesets/actiononly when there's actually something to do — a changeset is pending, or the localpackage.jsonversion isn't the one published on npm:Behavior across the three cases:
Notes
pending=0,0.4.0 == 0.4.0→ skip). The real paths only run on merge tomain.@changesets/clionce3.0.0is stable and past the cooldown; today only3.0.0-next.*prereleases carry the fix, so this guard sidesteps the bug in the meantime.