Skip to content

Commit 3f3739c

Browse files
committed
(GH-4696) Update GitVersion.Tool to 6.5.1 and migrate configuration
- Update GitVersion.Tool from 5.12.0 to 6.5.1 - Migrate GitVersion.yml configuration for v6.0.0+ compatibility: * Rename 'tag' property to 'label' (breaking change in v6.0.0) * Update deployment modes: ContinuousDelivery->ManualDeployment for master, ContinuousDeployment→ContinuousDelivery for develop * Remove deprecated properties: prevent-increment-of-merged-branch-version and track-merge-target * Add prevent-increment.when-current-commit-tagged for develop branch * Add explicit regex patterns for branch matching - Reconstruct LegacySemVerPadded format removed in GitVersion 6.0.0: * Add GetLegacySemVerPadded helper method to maintain backward compatibility * Format: {MajorMinorPatch}-{PreReleaseLabel}{PreReleaseNumber:D4} * Example: 6.1.0-alpha0041 - fixes #4696
1 parent fddc1d9 commit 3f3739c

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

GitVersion.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
next-version: 6.0.0
22
branches:
3-
master:
4-
regex: main
5-
mode: ContinuousDelivery
6-
tag:
3+
main:
4+
regex: ^main$
5+
mode: ManualDeployment
6+
label: null
77
increment: Patch
8-
prevent-increment-of-merged-branch-version: true
9-
track-merge-target: false
108
develop:
11-
mode: ContinuousDeployment
12-
tag: alpha
9+
regex: ^develop$
10+
mode: ContinuousDelivery
11+
label: alpha
1312
increment: Minor
14-
prevent-increment-of-merged-branch-version: false
15-
track-merge-target: true
13+
prevent-increment:
14+
when-current-commit-tagged: false
1615
ignore:
1716
sha:
1817
- 2a4757b270f7946122ba6622e3d2e72b2b2808a7

build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Twitter&version=5.0.0"
33

44
// Install .NET Core Global tools.
5-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0"
5+
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.5.1"
66
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.20.0"
77
#tool "dotnet:https://api.nuget.org/v3/index.json?package=sign&version=0.9.1-beta.25379.1&prerelease"
88

build/version.cake

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public record BuildVersion(
4444
});
4545

4646
version = context.EnvironmentVariable("GitVersion_MajorMinorPatch");
47-
semVersion = context.EnvironmentVariable("GitVersion_LegacySemVerPadded");
47+
var preReleaseNumberStr = context.EnvironmentVariable("GitVersion_PreReleaseNumber");
48+
semVersion = GetLegacySemVerPadded(
49+
context.EnvironmentVariable("GitVersion_MajorMinorPatch"),
50+
context.EnvironmentVariable("GitVersion_PreReleaseLabel"),
51+
!string.IsNullOrEmpty(preReleaseNumberStr) && int.TryParse(preReleaseNumberStr, out int num) ? num : (int?)null);
4852
milestone = string.Concat("v", version);
4953
}
5054

@@ -58,7 +62,10 @@ public record BuildVersion(
5862
});
5963

6064
version = assertedVersions.MajorMinorPatch;
61-
semVersion = assertedVersions.LegacySemVerPadded;
65+
semVersion = GetLegacySemVerPadded(
66+
assertedVersions.MajorMinorPatch,
67+
assertedVersions.PreReleaseLabel,
68+
assertedVersions.PreReleaseNumber);
6269
milestone = string.Concat("v", version);
6370
branchName = assertedVersions.BranchName;
6471

@@ -87,6 +94,28 @@ public record BuildVersion(
8794
);
8895
}
8996

97+
/// <summary>
98+
/// Constructs the LegacySemVerPadded format that was removed in GitVersion 6.0.0.
99+
/// Format: {MajorMinorPatch}-{PreReleaseLabel}{PreReleaseNumber:D4}
100+
/// Example: 6.1.0-alpha-0041
101+
/// </summary>
102+
private static string GetLegacySemVerPadded(string majorMinorPatch, string preReleaseLabel, int? preReleaseNumber)
103+
{
104+
if (string.IsNullOrEmpty(majorMinorPatch))
105+
{
106+
return string.Empty;
107+
}
108+
109+
// If no pre-release label or number, return just the version
110+
if (string.IsNullOrEmpty(preReleaseLabel) || !preReleaseNumber.HasValue)
111+
{
112+
return majorMinorPatch;
113+
}
114+
115+
// Format with 4-digit padding
116+
return $"{majorMinorPatch}-{preReleaseLabel}{preReleaseNumber.Value:D4}";
117+
}
118+
90119
public static string ReadSolutionInfoVersion(ICakeContext context)
91120
{
92121
var solutionInfo = context.ParseAssemblyInfo("./src/SolutionInfo.cs");

0 commit comments

Comments
 (0)