From f02799d050751452847690a324d05914b8d4b679 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Mon, 14 Apr 2025 13:07:20 +0200 Subject: [PATCH] Added the prepare command --- app/Build/Commands/UpdateMetadataCommands.cs | 33 +++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/app/Build/Commands/UpdateMetadataCommands.cs b/app/Build/Commands/UpdateMetadataCommands.cs index 088fa108..18539955 100644 --- a/app/Build/Commands/UpdateMetadataCommands.cs +++ b/app/Build/Commands/UpdateMetadataCommands.cs @@ -11,6 +11,25 @@ namespace Build.Commands; public sealed partial class UpdateMetadataCommands { + [Command("prepare", Description = "Prepare the next release")] + public async Task Prepare(PrepareAction action) + { + var appVersion = await this.UpdateAppVersion(action); + if (!string.IsNullOrWhiteSpace(appVersion)) + { + var buildNumber = await this.IncreaseBuildNumber(); + var buildTime = await this.UpdateBuildTime(); + await this.UpdateChangelog(buildNumber, appVersion, buildTime); + await this.UpdateDotnetVersion(); + await this.UpdateRustVersion(); + await this.UpdateMudBlazorVersion(); + await this.UpdateTauriVersion(); + await this.UpdateProjectCommitHash(); + await this.UpdateLicenceYear(Path.GetFullPath(Path.Combine(Environment.GetAIStudioDirectory(), "..", "..", "LICENSE.md"))); + await this.UpdateLicenceYear(Path.GetFullPath(Path.Combine(Environment.GetAIStudioDirectory(), "Pages", "About.razor.cs"))); + } + } + [Command("build", Description = "Build MindWork AI Studio")] public async Task Build() { @@ -152,6 +171,9 @@ public sealed partial class UpdateMetadataCommands return; } + // Right now, the build time is formatted as "yyyy-MM-dd HH:mm:ss UTC", but must remove the seconds: + buildTime = buildTime[..^7] + " UTC"; + const string CODE_START = """ LOGS = @@ -187,14 +209,14 @@ public sealed partial class UpdateMetadataCommands await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM); } - private async Task UpdateAppVersion(PrepareAction action) + private async Task UpdateAppVersion(PrepareAction action) { const int APP_VERSION_INDEX = 0; if (action == PrepareAction.NONE) { Console.WriteLine("- No action specified. Skipping app version update."); - return; + return string.Empty; } var pathMetadata = Environment.GetMetadataPath(); @@ -228,6 +250,7 @@ public sealed partial class UpdateMetadataCommands lines[APP_VERSION_INDEX] = updatedAppVersion; await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM); + return updatedAppVersion; } private async Task UpdateLicenceYear(string licenceFilePath) @@ -423,7 +446,7 @@ public sealed partial class UpdateMetadataCommands """; } - private async Task IncreaseBuildNumber() + private async Task IncreaseBuildNumber() { const int BUILD_NUMBER_INDEX = 2; var pathMetadata = Environment.GetMetadataPath(); @@ -434,9 +457,10 @@ public sealed partial class UpdateMetadataCommands lines[BUILD_NUMBER_INDEX] = buildNumber.ToString(); await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM); + return buildNumber; } - private async Task UpdateBuildTime() + private async Task UpdateBuildTime() { const int BUILD_TIME_INDEX = 1; var pathMetadata = Environment.GetMetadataPath(); @@ -447,6 +471,7 @@ public sealed partial class UpdateMetadataCommands lines[BUILD_TIME_INDEX] = buildTime; await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM); + return buildTime; } [GeneratedRegex("""(?ms).?(NET\s+SDK|SDK\s+\.NET)\s*:\s+Version:\s+(?[0-9.]+).+Commit:\s+(?[a-zA-Z0-9]+).+Host:\s+Version:\s+(?[0-9.]+).+Commit:\s+(?[a-zA-Z0-9]+)""")]