diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 703effc1..f5ba225d 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -84,8 +84,8 @@ "PublishRelease", "PublishWin64FrameworkDependent", "PublishWin64SelfContained", - "Restore", - "SetVersion" + "ReportInfo", + "Restore" ] } }, @@ -107,8 +107,8 @@ "PublishRelease", "PublishWin64FrameworkDependent", "PublishWin64SelfContained", - "Restore", - "SetVersion" + "ReportInfo", + "Restore" ] } }, diff --git a/src/01-Build/NukeBuild/Build.cs b/src/01-Build/NukeBuild/Build.cs index eb2e1e30..485c4060 100644 --- a/src/01-Build/NukeBuild/Build.cs +++ b/src/01-Build/NukeBuild/Build.cs @@ -7,7 +7,6 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.GitHub; using Nuke.Common.Tools.GitVersion; -using Nuke.Common.Tools.MinVer; using Nuke.Common.Tools.MSBuild; using Nuke.Common.Tools.NerdbankGitVersioning; using Octokit; @@ -39,9 +38,6 @@ public sealed class Build : NukeBuild [GitRepository] private readonly GitRepository GitRepository; - [MinVer] - private readonly MinVer MinVer; - [Nuke.Common.Parameter("GitHub Token")] private readonly string GitHubToken; @@ -65,19 +61,33 @@ public sealed class Build : NukeBuild private GitHubActions GitHubActions => GitHubActions.Instance; /// - /// Manual versioning for now. + /// Returns the version as defined by VERSION (eg. "2.3.4"). + /// + private string SemVerVersion => File.ReadAllText(VersionFile).Trim(); + + /// + /// Returns the version for use in assembly versioning. /// - private Target SetVersion => _ => _ + private string AssemblyVersion => $"{SemVerVersion}"; + + /// + /// Returns the version for use in assembly versioning. + /// + private string InformationalVersion => $"{SemVerVersion}.{DateTimeOffset.UtcNow:yyyyMMdd}+{GitRepository.Commit}"; + + private Target ReportInfo => _ => _ .Executes(() => { - Environment.SetEnvironmentVariable("MINVERVERSIONOVERRIDE", File.ReadAllText(VersionFile).Trim()); + Log.Information("SemVerVersion:{SemVerVersion}", SemVerVersion); + Log.Information("AssemblyVersion:{AssemblyVersion}", AssemblyVersion); + Log.Information("InformationalVersion:{InformationalVersion}", InformationalVersion); }); /// /// Clean output directories. /// private Target Clean => _ => _ - .DependsOn(SetVersion) + .DependsOn(ReportInfo) .Executes(() => { OutputDirectory.CreateOrCleanDirectory(); @@ -105,6 +115,8 @@ public sealed class Build : NukeBuild var st = StagingDirectory / "win-x64_framework-dependent"; DotNetPublish(_ => _ + .SetAssemblyVersion(AssemblyVersion) + .SetInformationalVersion(InformationalVersion) .SetConfiguration(Configuration) .SetFramework("net8.0-windows") .SetProject(Solution._0_Host.Wtq_Host_Windows) @@ -131,6 +143,8 @@ public sealed class Build : NukeBuild var staging = StagingDirectory / "win-x64_self-contained"; DotNetPublish(_ => _ + .SetAssemblyVersion(AssemblyVersion) + .SetInformationalVersion(InformationalVersion) .SetConfiguration(Configuration) .SetFramework("net8.0-windows") .SetProject(Solution._0_Host.Wtq_Host_Windows) @@ -156,13 +170,13 @@ public sealed class Build : NukeBuild var sha256 = Convert.ToHexString(await SHA256.HashDataAsync(File.OpenRead(PathToWin64SelfContainedZip))).ToLowerInvariant(); var manifest = tpl - .Replace("$PACKAGE_VERSION$", MinVer.MinVerVersion, StringComparison.OrdinalIgnoreCase) - .Replace("$GH_RELEASE_VERSION$", $"v{MinVer.MinVerVersion}", StringComparison.OrdinalIgnoreCase) + .Replace("$PACKAGE_VERSION$", SemVerVersion, StringComparison.OrdinalIgnoreCase) + .Replace("$GH_RELEASE_VERSION$", $"v{SemVerVersion}", StringComparison.OrdinalIgnoreCase) .Replace("$SELF_CONTAINED_SHA256$", sha256, StringComparison.OrdinalIgnoreCase); await File.WriteAllTextAsync(RootDirectory / "scoop" / "wtq-latest.json", manifest); await File.WriteAllTextAsync(RootDirectory / "scoop" / "wtq-nightly.json", manifest); - await File.WriteAllTextAsync(RootDirectory / "scoop" / $"wtq-{MinVer.MinVerVersion}.json", manifest); + await File.WriteAllTextAsync(RootDirectory / "scoop" / $"wtq-{SemVerVersion}.json", manifest); }); /// @@ -172,7 +186,7 @@ public sealed class Build : NukeBuild .Executes(async () => { var templateRoot = RootDirectory / "winget" / "_template"; - var manifestRoot = RootDirectory / "winget" / MinVer.MinVerVersion; + var manifestRoot = RootDirectory / "winget" / SemVerVersion; var prefix = "flyingpie.windows-terminal-quake"; var sha256 = Convert.ToHexString(await SHA256.HashDataAsync(File.OpenRead(PathToWin64SelfContainedZip))).ToLowerInvariant(); @@ -192,8 +206,8 @@ public sealed class Build : NukeBuild var target = manifestRoot / fn; var manifest = tpl - .Replace("$PACKAGE_VERSION$", MinVer.MinVerVersion, StringComparison.OrdinalIgnoreCase) - .Replace("$GH_RELEASE_VERSION$", $"v{MinVer.MinVerVersion}", StringComparison.OrdinalIgnoreCase) + .Replace("$PACKAGE_VERSION$", SemVerVersion, StringComparison.OrdinalIgnoreCase) + .Replace("$GH_RELEASE_VERSION$", $"v{SemVerVersion}", StringComparison.OrdinalIgnoreCase) .Replace("$SELF_CONTAINED_SHA256$", sha256, StringComparison.OrdinalIgnoreCase); await File.WriteAllTextAsync(target, manifest); @@ -217,10 +231,10 @@ public sealed class Build : NukeBuild var (owner, name) = (GitRepository.GetGitHubOwner(), GitRepository.GetGitHubName()); - var ghRelease = await GitHubTasks.GitHubClient.GetOrCreateGitHubReleaseAsync(owner, name, MinVer.MinVerVersion); + var ghRelease = await GitHubTasks.GitHubClient.GetOrCreateGitHubReleaseAsync(owner, name, SemVerVersion); // Update release notes. - var latestChangeLog = await NukeExtensions.GetChangeLogEntryAsync(ChangeLogFile, MinVer); + var latestChangeLog = await NukeExtensions.GetChangeLogEntryAsync(ChangeLogFile, SemVerVersion); await GitHubTasks .GitHubClient diff --git a/src/01-Build/NukeBuild/NukeBuild.csproj b/src/01-Build/NukeBuild/NukeBuild.csproj index 07d68630..90af23d2 100644 --- a/src/01-Build/NukeBuild/NukeBuild.csproj +++ b/src/01-Build/NukeBuild/NukeBuild.csproj @@ -13,8 +13,4 @@ - - - - diff --git a/src/01-Build/NukeBuild/NukeExtensions.cs b/src/01-Build/NukeBuild/NukeExtensions.cs index 658620fd..b83a5cbf 100644 --- a/src/01-Build/NukeBuild/NukeExtensions.cs +++ b/src/01-Build/NukeBuild/NukeExtensions.cs @@ -1,5 +1,4 @@ -using Nuke.Common.Tools.MinVer; -using Octokit; +using Octokit; using Serilog; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -14,7 +13,7 @@ public static partial class NukeExtensions public static async Task GetChangeLogEntryAsync( string path, - MinVer ver) + string ver) { var inCurr = false; var headerRegex = ChangeLogVersionHeaderRegex(); @@ -29,9 +28,7 @@ public static async Task GetChangeLogEntryAsync( { // See if this version header matches the one we're publishing. // If it is, we need to start reading the contents. - if (match.Groups["major"].Value == ver.MinVerMajor && - match.Groups["minor"].Value == ver.MinVerMinor && - match.Groups["patch"].Value == ver.MinVerPatch) + if (match.Groups["semver"].Value == ver) { inCurr = true; continue; @@ -111,6 +108,6 @@ public static async Task UploadReleaseAssetToGithub( await client.Repository.Release.UploadAsset(release, assetUpload); } - [GeneratedRegex(@"^## \[(?\d+)\.(?\d+)\.(?\d+)\]")] + [GeneratedRegex(@"^## \[(?\d+\.?\d+\.?\d+)\]")] private static partial Regex ChangeLogVersionHeaderRegex(); } \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 35da132c..a2ce26ad 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -37,7 +37,6 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -51,11 +50,4 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 - - \ No newline at end of file diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 03628bcf..74546a0b 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -6,7 +6,6 @@ - diff --git a/src/Wtq.sln b/src/Wtq.sln index be7ed311..c2fbc31a 100644 --- a/src/Wtq.sln +++ b/src/Wtq.sln @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00-Sln", "00-Sln", "{79182C build.cmd = build.cmd build.ps1 = build.ps1 build.sh = build.sh + ..\CHANGELOG.md = ..\CHANGELOG.md Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props global.json = global.json