@@ -15,17 +15,28 @@ public record DockerHubCredentials(string Username, string Password);
15
15
16
16
public record ChocolateyCredentials ( string ApiKey ) ;
17
17
18
- public record BuildVersion ( GitVersion GitVersion , string ? Version , string ? Milestone , string ? SemVersion , string ? NugetVersion , bool IsPreRelease )
18
+ public record BuildVersion ( GitVersion GitVersion , string ? Version , string ? Milestone , string ? SemVersion , string ? NugetVersion , string ? ChocolateyVersion , bool IsPreRelease )
19
19
{
20
20
public static BuildVersion Calculate ( GitVersion gitVersion )
21
21
{
22
22
var version = gitVersion . MajorMinorPatch ;
23
23
var semVersion = gitVersion . SemVer ;
24
24
var nugetVersion = gitVersion . SemVer ;
25
+ var chocolateyVersion = gitVersion . MajorMinorPatch ;
26
+
27
+ if ( ! string . IsNullOrWhiteSpace ( gitVersion . PreReleaseTag ) )
28
+ {
29
+ // Chocolatey does not support pre-release tags with dots, so we replace them with dashes
30
+ // if the pre-release tag is a number, we add a "a" prefix to the pre-release tag
31
+ // the trick should be removed when Chocolatey supports semver 2.0
32
+ var prefix = int . TryParse ( gitVersion . PreReleaseLabel , out _ ) ? "a" : string . Empty ;
33
+ chocolateyVersion += $ "-{ prefix } { gitVersion . PreReleaseTag ? . Replace ( "." , "-" ) } ";
34
+ }
25
35
26
36
if ( ! string . IsNullOrWhiteSpace ( gitVersion . BuildMetaData ) )
27
37
{
28
38
semVersion += $ "-{ gitVersion . BuildMetaData } ";
39
+ chocolateyVersion += $ "-{ gitVersion . BuildMetaData } ";
29
40
nugetVersion += $ ".{ gitVersion . BuildMetaData } ";
30
41
}
31
42
@@ -35,6 +46,7 @@ public static BuildVersion Calculate(GitVersion gitVersion)
35
46
Milestone : semVersion ,
36
47
SemVersion : semVersion ,
37
48
NugetVersion : nugetVersion ? . ToLowerInvariant ( ) ,
49
+ ChocolateyVersion : chocolateyVersion ? . ToLowerInvariant ( ) ,
38
50
IsPreRelease : ! gitVersion . PreReleaseLabel . IsNullOrEmpty ( )
39
51
) ;
40
52
}
0 commit comments