Added a release command

This commit is contained in:
Thorsten Sommer 2025-04-14 13:32:05 +02:00
parent f02799d050
commit 70610f6e20
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 52 additions and 5 deletions

View File

@ -16,6 +16,9 @@ public sealed partial class CollectI18NKeysCommand
if(!Environment.IsWorkingDirectoryValid()) if(!Environment.IsWorkingDirectoryValid())
return; return;
Console.WriteLine("=========================");
Console.Write("- Collecting I18N keys ...");
var cwd = Environment.GetAIStudioDirectory(); var cwd = Environment.GetAIStudioDirectory();
var binPath = Path.Join(cwd, "bin"); var binPath = Path.Join(cwd, "bin");
var objPath = Path.Join(cwd, "obj"); var objPath = Path.Join(cwd, "obj");
@ -53,6 +56,7 @@ public sealed partial class CollectI18NKeysCommand
} }
Console.WriteLine($" {counter:###,###} files processed."); Console.WriteLine($" {counter:###,###} files processed.");
Console.WriteLine();
} }
private List<string> FindAllTextTags(ReadOnlySpan<char> fileContent) private List<string> FindAllTextTags(ReadOnlySpan<char> fileContent)

View File

@ -11,9 +11,40 @@ namespace Build.Commands;
public sealed partial class UpdateMetadataCommands public sealed partial class UpdateMetadataCommands
{ {
[Command("prepare", Description = "Prepare the next release")] [Command("release", Description = "Prepare & build the next release")]
public async Task Release(PrepareAction action)
{
if(!Environment.IsWorkingDirectoryValid())
return;
// Prepare the metadata for the next release:
await this.Prepare(action);
// Build once to allow the Rust compiler to read the changed metadata
// and to update all .NET artifacts:
await this.Build();
// Now, we update the web assets (which may were updated by the first build):
new UpdateWebAssetsCommand().UpdateWebAssets();
// Collect the I18N keys from the source code. This step yields a I18N file
// that must be part of the final release:
await new CollectI18NKeysCommand().CollectI18NKeys();
// Build the final release, where Rust knows the updated metadata, the .NET
// artifacts are already in place, and .NET knows the updated web assets, etc.:
await this.Build();
}
[Command("prepare", Description = "Prepare the metadata for the next release")]
public async Task Prepare(PrepareAction action) public async Task Prepare(PrepareAction action)
{ {
if(!Environment.IsWorkingDirectoryValid())
return;
Console.WriteLine("==============================");
Console.WriteLine("- Prepare the metadata for the next release ...");
var appVersion = await this.UpdateAppVersion(action); var appVersion = await this.UpdateAppVersion(action);
if (!string.IsNullOrWhiteSpace(appVersion)) if (!string.IsNullOrWhiteSpace(appVersion))
{ {
@ -27,12 +58,16 @@ public sealed partial class UpdateMetadataCommands
await this.UpdateProjectCommitHash(); await this.UpdateProjectCommitHash();
await this.UpdateLicenceYear(Path.GetFullPath(Path.Combine(Environment.GetAIStudioDirectory(), "..", "..", "LICENSE.md"))); await this.UpdateLicenceYear(Path.GetFullPath(Path.Combine(Environment.GetAIStudioDirectory(), "..", "..", "LICENSE.md")));
await this.UpdateLicenceYear(Path.GetFullPath(Path.Combine(Environment.GetAIStudioDirectory(), "Pages", "About.razor.cs"))); await this.UpdateLicenceYear(Path.GetFullPath(Path.Combine(Environment.GetAIStudioDirectory(), "Pages", "About.razor.cs")));
Console.WriteLine();
} }
} }
[Command("build", Description = "Build MindWork AI Studio")] [Command("build", Description = "Build MindWork AI Studio")]
public async Task Build() public async Task Build()
{ {
if(!Environment.IsWorkingDirectoryValid())
return;
// //
// Build the .NET project: // Build the .NET project:
// //
@ -156,7 +191,10 @@ public sealed partial class UpdateMetadataCommands
if(foundRustIssue) if(foundRustIssue)
Console.WriteLine(); Console.WriteLine();
else else
{
Console.WriteLine(" completed successfully."); Console.WriteLine(" completed successfully.");
Console.WriteLine();
}
} }
private async Task UpdateChangelog(int buildNumber, string appVersion, string buildTime) private async Task UpdateChangelog(int buildNumber, string appVersion, string buildTime)

View File

@ -14,13 +14,17 @@ public sealed class UpdateWebAssetsCommand
if(!Environment.IsWorkingDirectoryValid()) if(!Environment.IsWorkingDirectoryValid())
return; return;
Console.WriteLine("=========================");
Console.Write("- Updating web assets ...");
var rid = Environment.GetRidsForCurrentOS().First(); var rid = Environment.GetRidsForCurrentOS().First();
var cwd = Environment.GetAIStudioDirectory(); var cwd = Environment.GetAIStudioDirectory();
var contentPath = Path.Join(cwd, "bin", "release", Environment.DOTNET_VERSION, rid.ToName(), "publish", "wwwroot", "_content"); var contentPath = Path.Join(cwd, "bin", "release", Environment.DOTNET_VERSION, rid.ToName(), "publish", "wwwroot", "_content");
var isMudBlazorDirectoryPresent = Directory.Exists(Path.Join(contentPath, "MudBlazor")); var isMudBlazorDirectoryPresent = Directory.Exists(Path.Join(contentPath, "MudBlazor"));
if (!isMudBlazorDirectoryPresent) if (!isMudBlazorDirectoryPresent)
{ {
Console.WriteLine($"No web assets found for RID '{rid}'. Please publish the project first."); Console.WriteLine();
Console.WriteLine($"- Error: No web assets found for RID '{rid}'. Please publish the project first.");
return; return;
} }
@ -40,5 +44,6 @@ public sealed class UpdateWebAssetsCommand
} }
Console.WriteLine($" {counter:###,###} web assets updated successfully."); Console.WriteLine($" {counter:###,###} web assets updated successfully.");
Console.WriteLine();
} }
} }