changed build versioning to get rid of GitVersion dependency
Some checks failed
CI Build / CI Build API (pull_request) Failing after 32s
Some checks failed
CI Build / CI Build API (pull_request) Failing after 32s
This commit is contained in:
parent
4058972e82
commit
db05731456
@ -32,8 +32,6 @@ class Build : NukeBuild
|
|||||||
|
|
||||||
[Solution] readonly Solution Solution;
|
[Solution] readonly Solution Solution;
|
||||||
|
|
||||||
[GitVersion(NoFetch = true)] readonly GitVersion GitVersion;
|
|
||||||
|
|
||||||
AbsolutePath SourceDirectory => RootDirectory;
|
AbsolutePath SourceDirectory => RootDirectory;
|
||||||
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
||||||
|
|
||||||
@ -44,6 +42,10 @@ class Build : NukeBuild
|
|||||||
[Parameter("NuGet API key")]
|
[Parameter("NuGet API key")]
|
||||||
readonly string NuGetApiKey;
|
readonly string NuGetApiKey;
|
||||||
|
|
||||||
|
[Parameter("Build number override")]
|
||||||
|
readonly string BuildNumber
|
||||||
|
= Environment.GetEnvironmentVariable("GITHUB_RUN_NUMBER") ?? $"{0}";
|
||||||
|
|
||||||
[Parameter("Gitea Nuget package source name")]
|
[Parameter("Gitea Nuget package source name")]
|
||||||
readonly string GiteaNugetSourceName = Environment.GetEnvironmentVariable("GITEA_NUGET_SOURCE_NAME");
|
readonly string GiteaNugetSourceName = Environment.GetEnvironmentVariable("GITEA_NUGET_SOURCE_NAME");
|
||||||
|
|
||||||
@ -61,9 +63,9 @@ class Build : NukeBuild
|
|||||||
Target Compile => _ => _
|
Target Compile => _ => _
|
||||||
.Executes(() =>
|
.Executes(() =>
|
||||||
{
|
{
|
||||||
var semVer = GitVersion.AssemblySemVer;
|
var semVer = Version;
|
||||||
var semFileVer = GitVersion.AssemblySemFileVer;
|
var semFileVer = Version;
|
||||||
var informationalVersion = GitVersion.InformationalVersion;
|
var informationalVersion = Version;
|
||||||
|
|
||||||
Log.Logger.Information("AssemblySemVer: {semVer}", semVer);
|
Log.Logger.Information("AssemblySemVer: {semVer}", semVer);
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ class Build : NukeBuild
|
|||||||
.SetProject(SourceDirectory / "Provider" / $"{LibraryProjectName}.csproj")
|
.SetProject(SourceDirectory / "Provider" / $"{LibraryProjectName}.csproj")
|
||||||
.SetConfiguration(Configuration)
|
.SetConfiguration(Configuration)
|
||||||
.SetOutputDirectory(NuGetPackagesDirectory)
|
.SetOutputDirectory(NuGetPackagesDirectory)
|
||||||
.SetVersion(GitVersion.NuGetVersionV2)
|
.SetVersion(Version)
|
||||||
.SetNoBuild(true)
|
.SetNoBuild(true)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -107,18 +109,48 @@ class Build : NukeBuild
|
|||||||
DotNetTasks.DotNetNuGetPush(s => s
|
DotNetTasks.DotNetNuGetPush(s => s
|
||||||
.SetSource(GiteaNugetSourceName)
|
.SetSource(GiteaNugetSourceName)
|
||||||
.SetApiKey(NuGetApiKey)
|
.SetApiKey(NuGetApiKey)
|
||||||
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{GitVersion.NuGetVersionV2}.snupkg"));
|
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{Version}.snupkg"));
|
||||||
|
|
||||||
DotNetTasks.DotNetNuGetPush(s => s
|
DotNetTasks.DotNetNuGetPush(s => s
|
||||||
.SetSource(GiteaNugetSourceName)
|
.SetSource(GiteaNugetSourceName)
|
||||||
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{GitVersion.NuGetVersionV2}.nupkg"));
|
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{Version}.nupkg"));
|
||||||
});
|
});
|
||||||
|
|
||||||
Target CreateAndPushGitTag => _ => _
|
Target CreateAndPushGitTag => _ => _
|
||||||
.Executes(() =>
|
.Executes(() =>
|
||||||
{
|
{
|
||||||
var gitTag = $"{GitVersion.NuGetVersionV2}";
|
var gitTag = $"{Version}";
|
||||||
GitTasks.Git($"tag {gitTag}");
|
GitTasks.Git($"tag {gitTag}");
|
||||||
GitTasks.Git($"push origin {gitTag}");
|
GitTasks.Git($"push origin {gitTag}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private string Version
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (version == null)
|
||||||
|
{
|
||||||
|
version = GetVersion();
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string version = null;
|
||||||
|
|
||||||
|
private string GetVersion()
|
||||||
|
{
|
||||||
|
Log.Information("GitHub run number is {number}", Environment.GetEnvironmentVariable("GITHUB_RUN_NUMBER"));
|
||||||
|
var buildNumber = BuildNumber;
|
||||||
|
if (string.IsNullOrEmpty(buildNumber))
|
||||||
|
{
|
||||||
|
return "1.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentDateTime = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
|
var assembledVersion = $"{currentDateTime.Year}.{currentDateTime.Month}.{buildNumber}";
|
||||||
|
Log.Information("Assembled version: {assembledVersion}", assembledVersion);
|
||||||
|
return assembledVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user