net9-update-refactorings #1
@ -32,8 +32,6 @@ class Build : NukeBuild
|
||||
|
||||
[Solution] readonly Solution Solution;
|
||||
|
||||
[GitVersion(NoFetch = true)] readonly GitVersion GitVersion;
|
||||
|
||||
AbsolutePath SourceDirectory => RootDirectory;
|
||||
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
||||
|
||||
@ -44,6 +42,10 @@ class Build : NukeBuild
|
||||
[Parameter("NuGet API key")]
|
||||
readonly string NuGetApiKey;
|
||||
|
||||
[Parameter("Build number override")]
|
||||
readonly string BuildNumber
|
||||
= Environment.GetEnvironmentVariable("GITHUB_RUN_NUMBER") ?? $"{0}";
|
||||
|
||||
[Parameter("Gitea Nuget package source name")]
|
||||
readonly string GiteaNugetSourceName = Environment.GetEnvironmentVariable("GITEA_NUGET_SOURCE_NAME");
|
||||
|
||||
@ -61,9 +63,9 @@ class Build : NukeBuild
|
||||
Target Compile => _ => _
|
||||
.Executes(() =>
|
||||
{
|
||||
var semVer = GitVersion.AssemblySemVer;
|
||||
var semFileVer = GitVersion.AssemblySemFileVer;
|
||||
var informationalVersion = GitVersion.InformationalVersion;
|
||||
var semVer = Version;
|
||||
var semFileVer = Version;
|
||||
var informationalVersion = Version;
|
||||
|
||||
Log.Logger.Information("AssemblySemVer: {semVer}", semVer);
|
||||
|
||||
@ -95,7 +97,7 @@ class Build : NukeBuild
|
||||
.SetProject(SourceDirectory / "Provider" / $"{LibraryProjectName}.csproj")
|
||||
.SetConfiguration(Configuration)
|
||||
.SetOutputDirectory(NuGetPackagesDirectory)
|
||||
.SetVersion(GitVersion.NuGetVersionV2)
|
||||
.SetVersion(Version)
|
||||
.SetNoBuild(true)
|
||||
);
|
||||
});
|
||||
@ -107,18 +109,48 @@ class Build : NukeBuild
|
||||
DotNetTasks.DotNetNuGetPush(s => s
|
||||
.SetSource(GiteaNugetSourceName)
|
||||
.SetApiKey(NuGetApiKey)
|
||||
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{GitVersion.NuGetVersionV2}.snupkg"));
|
||||
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{Version}.snupkg"));
|
||||
|
||||
DotNetTasks.DotNetNuGetPush(s => s
|
||||
.SetSource(GiteaNugetSourceName)
|
||||
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{GitVersion.NuGetVersionV2}.nupkg"));
|
||||
.SetTargetPath(NuGetPackagesDirectory / $"{LibraryProjectName}.{Version}.nupkg"));
|
||||
});
|
||||
|
||||
Target CreateAndPushGitTag => _ => _
|
||||
.Executes(() =>
|
||||
{
|
||||
var gitTag = $"{GitVersion.NuGetVersionV2}";
|
||||
var gitTag = $"{Version}";
|
||||
GitTasks.Git($"tag {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