fix(release-script): stop the cut when a git add, commit, tag or push fails - #692
Merged
Merged
Conversation
… fails PowerShell does not stop on a native command's non-zero exit. On the 2.4.0 cut a stale .git/index.lock failed the release add and commit; the script printed "commit: Release v2.4.0" anyway and Step 7 tagged the commit before it. -SkipPush kept it off origin. - cut-release.ps1: Invoke-Git runs git and throws on a non-zero exit, naming the call. Every add, commit, tag and push in both the release and the -PostReleaseOnly paths goes through it. - ReleaseScriptGitExitCodeGuardTest: no bare repository-changing git call is left, and the helper still throws on $LASTEXITCODE. - release-script-check.yml: a new step runs Invoke-Git against a throwaway repository holding index.lock, with a bare-git control, and checks that paths and messages with spaces arrive intact. - release-process.md: the Step 6-8 behaviour and a troubleshooting row for a held index lock.
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.
Why
PowerShell does not stop on a native command's non-zero exit, and
cut-release.ps1ran its releasegit add,git commit,git tagandgit pushbare. On the 2.4.0 cut a stale.git/index.lockfailed the release add and commit. The script printedcommit: Release v2.4.0anyway, and Step 7 taggedfa104ba5, the commit before the release.-SkipPushkept that tag off origin; without it the wrong commit would have been tagged and pushed, and the tag would have started the publish workflows.What changed
scripts/cut-release.ps1—Invoke-Gitruns git and throwsgit <args> failed (exit N); nothing after it ran.on a non-zero exit. All eight repository-changing calls go through it: add, commit, tag and push in the release path, and add, commit and push in-PostReleaseOnly. A release commit with nothing staged now stops the cut too, where it used to pass silently.ReleaseScriptGitExitCodeGuardTest(core, documentation guards) — fails on any baregit add|commit|tag|push|reset|checkout|merge|rmstatement in the script, and on anInvoke-Gitthat no longer throws on$LASTEXITCODE.release-script-check.yml— new step A failed git mutation stops the cut. It liftsInvoke-Gitby AST and runs it against a throwaway repository holdingindex.lock:The step resets
$LASTEXITCODEat the end, because the Actions pwsh wrapper exits with it and the last git call fails on purpose.docs/contributing/release-process.md— the Step 6–8 behaviour, and a troubleshooting row for a held index lock. The row says what a Step 6 stop versus a Step 7 stop leaves behind.Why not
$PSNativeCommandUseErrorActionPreference = $truefor the whole script: it would turn every native non-zero exit into an exception, including thegit status/rev-parseprobes and Maven calls the script already checks itself. That changes far more than this bug.Lane: build / release tooling. No runtime code, no public API.
Verification
./mvnw -B -ntp test -f core/pom.xml -Dtest='com.demcha.documentation.**'— 145 tests, 0 failures, BUILD SUCCESS (2 new).git commit -m $commitMsgrestored bare →everyGitMutationGoesThroughTheCheckedHelperfails, naming line 1897;throwreplaced byWrite-Host→theHelperThrowsOnANonZeroExitfails, and so does the new workflow step.$ErrorActionPreference = 'stop'…exit $LASTEXITCODE): exit 0 as written, exit 1 with the throw removed. Before the$LASTEXITCODEreset it exited 128 despite passing every check.cut-release.ps1 -Version 2.4.1 -Branch develop -DryRun -SkipShowcaseand-PostReleaseOnly -Branch develop -DryRunboth complete with exit 0.