fix(ci): fail the release run when npm publish fails - #105
Merged
Conversation
The publish step piped changeset publish through tee under the Actions default shell, which has no pipefail, so a failed publish exited 0 and the run concluded success. Declare shell: bash with set -euo pipefail and branch on the pipeline status. Replace the published boolean with a tri-state result output — published, none, failed — so a hard failure is no longer indistinguishable from having nothing to release, and report the failed state in the job summary instead of "No new versions to publish." Give the workflow-authored back-merge and release-branch commits the correct author identity, and drop the unused has_changesets step.
Contributor
|
Thanks for the pull request — it is in the queue and a maintainer will review it. This repository is maintained on a weekly cadence. Anything opened from outside gets What happens next:
If this is a security fix for an unreported vulnerability, please close it and use |
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.
A failed
npm publishproduced a green release run whose summary read "No new versions to publish." The publish step's exit status was masked and a hard failure was indistinguishable from a no-op.What changed
release.yml— exit status is no longer masked.pnpm changeset publish 2>&1 | tee …ran under the Actions default shell (bash -e {0}), which does not setpipefail, so the pipeline reportedtee's status of 0 and-enever fired. The step now declaresshell: bashandset -euo pipefail, and branches on the pipeline's own status.release.yml— failure and no-op are now distinct. Thepublishedboolean became a tri-stateresultoutput:resultpublishednonefailedchangeset publishexited non-zeroAll downstream gates read
result == 'published';No release neededreadsresult == 'none'; a newPublish failedstep reports the failure in the job summary instead of the misleading no-op text.Correct commit identity. The workflow-authored back-merge in
release.yml, and the release-branch commit inrelease-branch.yml, both hard-codedgithub-actions[bot]. Both now use the repository's standard commit identity.release-branch.ymlcarried the identical defect and is fixed in the same pass so the next release does not reintroduce it.Dead code removed.
has_changesetswas computed and consumed by nothing; it read as a gate that existed. The tri-stateresultnow covers the no-op case properly.Verification
Both files parse, and
actionlintreports no errors (only pre-existing SC2129 style notes on untouched steps). The old and new scripts were run against a stub that mimics the failing publish:The other two paths were confirmed the same way: publish output with no
New tag:lines yieldsresult=noneand exit 0; output containingNew tag:yieldsresult=publishedand exit 0.Deliberately not changed
workflow_dispatch:was considered and declined. It would let a production publish be started from a button against a chosen ref, widening who can trigger a release. Re-running the failed jobs of an existing run (gh run rerun --failed) already re-triggers a release against the same commit without pushing the release branch, which solves the same problem without widening the trigger surface.