Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/build/Tasks/Package/PackageChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void Run(BuildContext context)

metaPackageSettings.Dependencies = new[]
{
new ChocolateyNuSpecDependency { Id = "GitVersion.Portable", Version = context.Version?.NugetVersion }
new ChocolateyNuSpecDependency { Id = "GitVersion.Portable", Version = context.Version?.ChocolateyVersion }
};

context.ChocolateyPack(metaPackageSettings);
Expand All @@ -48,7 +48,7 @@ private static ChocolateyPackSettings GetChocolateyPackSettings(BuildContextBase
var chocolateySettings = new ChocolateyPackSettings
{
Id = id,
Version = context.Version?.NugetVersion,
Version = context.Version?.ChocolateyVersion,
Title = "GitVersion",
Description = "Derives SemVer information from a repository following GitFlow or GitHubFlow.",
Authors = new[] { "GitTools and Contributors" },
Expand All @@ -61,7 +61,7 @@ private static ChocolateyPackSettings GetChocolateyPackSettings(BuildContextBase
IconUrl = new Uri("https://raw.githubusercontent.com/GitTools/graphics/master/GitVersion/Color/icon_100x100.png"),
RequireLicenseAcceptance = false,
Tags = new[] { "Git", "Versioning", "GitVersion", "GitFlowVersion", "GitFlow", "GitHubFlow", "SemVer" },
ReleaseNotes = new[] { $"https://github.com/GitTools/GitVersion/releases/tag/{context.Version?.NugetVersion}" },
ReleaseNotes = new[] { $"https://github.com/GitTools/GitVersion/releases/tag/{context.Version?.ChocolateyVersion}" },
OutputDirectory = Paths.Nuget,
LimitOutput = true,
};
Expand Down
14 changes: 13 additions & 1 deletion build/common/Utilities/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,28 @@ public record DockerHubCredentials(string Username, string Password);

public record ChocolateyCredentials(string ApiKey);

public record BuildVersion(GitVersion GitVersion, string? Version, string? Milestone, string? SemVersion, string? NugetVersion, bool IsPreRelease)
public record BuildVersion(GitVersion GitVersion, string? Version, string? Milestone, string? SemVersion, string? NugetVersion, string? ChocolateyVersion, bool IsPreRelease)
{
public static BuildVersion Calculate(GitVersion gitVersion)
{
var version = gitVersion.MajorMinorPatch;
var semVersion = gitVersion.SemVer;
var nugetVersion = gitVersion.SemVer;
var chocolateyVersion = gitVersion.MajorMinorPatch;

if (!string.IsNullOrWhiteSpace(gitVersion.PreReleaseTag))
{
// Chocolatey does not support pre-release tags with dots, so we replace them with dashes
// if the pre-release tag is a number, we add a "a" prefix to the pre-release tag
// the trick should be removed when Chocolatey supports semver 2.0
var prefix = int.TryParse(gitVersion.PreReleaseLabel, out _) ? "a" : string.Empty;
chocolateyVersion += $"-{prefix}{gitVersion.PreReleaseTag?.Replace(".", "-")}";
}

if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaData))
{
semVersion += $"-{gitVersion.BuildMetaData}";
chocolateyVersion += $"-{gitVersion.BuildMetaData}";
nugetVersion += $".{gitVersion.BuildMetaData}";
}

Expand All @@ -35,6 +46,7 @@ public static BuildVersion Calculate(GitVersion gitVersion)
Milestone: semVersion,
SemVersion: semVersion,
NugetVersion: nugetVersion?.ToLowerInvariant(),
ChocolateyVersion: chocolateyVersion?.ToLowerInvariant(),
IsPreRelease: !gitVersion.PreReleaseLabel.IsNullOrEmpty()
);
}
Expand Down