diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17244ce8a..89d75817a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,6 +106,16 @@ jobs: id: gitversion uses: gittools/actions/gitversion/execute@v4 + - name: Verify tag version output + if: startsWith(github.ref, 'refs/tags/v') + shell: pwsh + run: | + $expected = "${{ github.ref_name }}" -replace '^v', '' + $actual = "${{ steps.gitversion.outputs.semVer }}" + if ($actual -ne $expected) { + throw "GitVersion SemVer '$actual' did not match tag '$expected'." + } + - name: Restore dependencies run: dotnet restore diff --git a/GitVersion.yml b/GitVersion.yml index 04f2930ec..ca3ee2e24 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -5,7 +5,7 @@ assembly-versioning-scheme: MajorMinorPatch branches: main: regex: ^(master|main)$ - label: '' + label: alpha increment: Patch ignore: diff --git a/tests/OpenClaw.Tray.Tests/VersioningContractTests.cs b/tests/OpenClaw.Tray.Tests/VersioningContractTests.cs index a669996fe..a918df97a 100644 --- a/tests/OpenClaw.Tray.Tests/VersioningContractTests.cs +++ b/tests/OpenClaw.Tray.Tests/VersioningContractTests.cs @@ -58,6 +58,23 @@ public void ProductProjects_DoNotHardcodeReleaseVersion() string.Join(Environment.NewLine, offenders)); } + [Fact] + public void GitVersion_MainBranchPreservesAlphaReleaseTags() + { + var repoRoot = GetRepositoryRoot(); + var configPath = Path.Combine(repoRoot, "GitVersion.yml"); + var config = File.ReadAllText(configPath); + var mainBranchMatch = Regex.Match( + config, + @"(?ms)^ main:\s*$\r?\n(?.*?)(?=^ \S|\z)", + RegexOptions.CultureInvariant); + + Assert.True(mainBranchMatch.Success, "GitVersion.yml must configure the main branch."); + Assert.Matches( + @"(?m)^\s+label:\s*'?alpha'?\s*$", + mainBranchMatch.Groups["body"].Value); + } + [Fact] public void ActiveCodeAndTests_DoNotContainStaleReleaseVersion() {