From 842586aaea31539deec5a3104afc63c68ba3026a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 04:44:37 -0500 Subject: [PATCH] fix(release): don't fail the version step on a stale git exit code bump-version.ps1 checks that the new version isn't already tagged with 'git rev-parse --verify refs/tags/vX.Y.Z'. When the tag doesn't exist (the normal case) git exits 1, and that value was left in $LASTEXITCODE. GitHub Actions' pwsh wrapper ends each step with 'exit $LASTEXITCODE', so the "Increment version" step failed right after computing 1.1.10 -> 1.1.11. Nothing was committed or published. - Reset $LASTEXITCODE after the tag lookups in Test-Released. - End bump-version.ps1 and verify-package.ps1 with an explicit exit 0; real failures still surface through 'throw'. Verified under the Actions wrapper (pwsh -command ". ''" plus the appended LASTEXITCODE check): patch bump exits 0, a re-run with an untagged version exits 0 without bumping, a tag collision still exits 1, and package verification exits 0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012C6aJYkYBV2GSnSZwsd9GU --- .github/scripts/bump-version.ps1 | 18 ++++++++++++++---- .github/scripts/verify-package.ps1 | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/scripts/bump-version.ps1 b/.github/scripts/bump-version.ps1 index f07e762..b1e983a 100644 --- a/.github/scripts/bump-version.ps1 +++ b/.github/scripts/bump-version.ps1 @@ -43,11 +43,19 @@ function Set-Part([string] $name, [int] $value) { } function Test-Released([string] $version) { - foreach ($tag in @("v$version", $version)) { - & git rev-parse -q --verify "refs/tags/$tag" *> $null - if ($LASTEXITCODE -eq 0) { return $true } + try { + foreach ($tag in @("v$version", $version)) { + & git rev-parse -q --verify "refs/tags/$tag" *> $null + if ($LASTEXITCODE -eq 0) { return $true } + } + return $false + } + finally { + # 'git rev-parse --verify' exits 1 when a tag does not exist, which is the + # expected answer here. Don't let that leak out as the step's exit code: + # GitHub Actions' pwsh wrapper ends every step with 'exit $LASTEXITCODE'. + $global:LASTEXITCODE = 0 } - return $false } $major = Get-Part 'RELEASE_MAJOR' @@ -94,3 +102,5 @@ if ($env:GITHUB_OUTPUT) { "changed=$($changed.ToString().ToLowerInvariant())" ) | Add-Content -Path $env:GITHUB_OUTPUT } + +exit 0 diff --git a/.github/scripts/verify-package.ps1 b/.github/scripts/verify-package.ps1 index d975365..e0d6a31 100644 --- a/.github/scripts/verify-package.ps1 +++ b/.github/scripts/verify-package.ps1 @@ -106,3 +106,4 @@ if ($failures.Count -gt 0) { throw "Package verification failed with $($failures.Count) problem(s)." } Write-Host "Package $nupkgPath verified." +exit 0