Skip to content

Commit

Permalink
Fix version calculation on non windows (#621)
Browse files Browse the repository at this point in the history
+semver:patch
  • Loading branch information
hazzik authored Sep 18, 2023
1 parent 0dddee2 commit ef7694a
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions build/version.cake
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,34 @@ public class BuildVersion
string informationalVersion = null;
string milestone = null;

if (context.IsRunningOnWindows())
context.Information("Calculating Semantic Version");
if (!parameters.IsLocalBuild || parameters.IsPublishBuild || parameters.IsReleaseBuild)
{
context.Information("Calculating Semantic Version");
if (!parameters.IsLocalBuild || parameters.IsPublishBuild || parameters.IsReleaseBuild)
{
context.GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false,
OutputType = GitVersionOutput.BuildServer
});

version = context.EnvironmentVariable("GitVersion_MajorMinorPatch");
semVersion = context.EnvironmentVariable("GitVersion_LegacySemVerPadded");
assemblyVersion = context.EnvironmentVariable("GitVersion_AssemblySemVer");
informationalVersion = context.EnvironmentVariable("GitVersion_InformationalVersion");
milestone = string.Concat("v", version);
}

GitVersion assertedVersions = context.GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json,
context.GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false,
OutputType = GitVersionOutput.BuildServer
});

version = assertedVersions.MajorMinorPatch;
semVersion = assertedVersions.LegacySemVerPadded;
assemblyVersion = assertedVersions.AssemblySemVer;
informationalVersion = assertedVersions.InformationalVersion;
version = context.EnvironmentVariable("GitVersion_MajorMinorPatch");
semVersion = context.EnvironmentVariable("GitVersion_LegacySemVerPadded");
assemblyVersion = context.EnvironmentVariable("GitVersion_AssemblySemVer");
informationalVersion = context.EnvironmentVariable("GitVersion_InformationalVersion");
milestone = string.Concat("v", version);

context.Information("Calculated Semantic Version: {0}", semVersion);
}

GitVersion assertedVersions = context.GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json,
});

version = assertedVersions.MajorMinorPatch;
semVersion = assertedVersions.LegacySemVerPadded;
assemblyVersion = assertedVersions.AssemblySemVer;
informationalVersion = assertedVersions.InformationalVersion;
milestone = string.Concat("v", version);

context.Information("Calculated Semantic Version: {0}", semVersion);

var appVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();

return new BuildVersion
Expand Down

0 comments on commit ef7694a

Please sign in to comment.