Skip to content

Commit 1fa44fd

Browse files
andrei-balintclaude
andcommitted
build: version as v<epoch+height>, not v<height>
Resolve the version as the base tag's epoch plus the MinVer height (e.g. tag 1.9.1-v5 + height 1 -> 1.9.1-v6), so the number continues from the tag instead of restarting at the height. Fixes the post-merge release coming out as v1 (height 1) when it should follow v5. On the tag itself the height is 0, so the number equals the tag and re-tagging is seamless. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bbf5b2e commit 1fa44fd

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,16 @@ jobs:
156156
if ($LASTEXITCODE) { throw "minver failed ($LASTEXITCODE)" }
157157
# Version strings carry no build metadata in the archive/tag name; drop anything after '+'.
158158
$raw = $raw.Split('+')[0]
159-
# Collapse MinVer's "<base>-<epoch>.<height>" (e.g. 1.9.1-v5.21) into a single
160-
# auto-incrementing "<base>-v<height>" (e.g. 1.9.1-v21), matching the managed repo's
161-
# AdjustVersions target. The epoch tag is only a permanent counting anchor: v<height> rises
162-
# monotonically per commit, so no manual version tagging is needed. NEVER cut another -vN tag
163-
# on the line, or the height (hence v<N>) resets and the version would regress.
159+
# Turn MinVer's "<base>-v<epoch>.<height>" (base tag 1.9.1-v5 at height 1 -> 1.9.1-v5.1)
160+
# into a single continuing "<base>-v<epoch+height>" (e.g. 1.9.1-v6), matching the managed
161+
# repo's AdjustVersions target. The base tag sets the epoch and each commit past it
162+
# increments the number; on the tag itself height is 0 so the number equals the tag.
164163
$parts = $raw -split '-', 2
165164
$base = $parts[0]
166-
$height = if (($parts.Count -gt 1) -and ($parts[1] -match '\.(\d+)$')) { $Matches[1] } else { '0' }
167-
$version = "$base-v$height"
165+
$pre = if ($parts.Count -gt 1) { $parts[1] } else { '' }
166+
$epoch = if ($pre -match '^v(\d+)') { [int]$Matches[1] } else { 0 }
167+
$height = if ($pre -match '\.(\d+)$') { [int]$Matches[1] } else { 0 }
168+
$version = "$base-v$($epoch + $height)"
168169
Write-Host "Resolved version: $version (from MinVer '$raw')"
169170
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
170171

0 commit comments

Comments
 (0)