Added update changelog method

This commit is contained in:
Thorsten Sommer 2025-04-13 21:28:54 +02:00
parent 164f28e131
commit 92ed4fcb9d
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -15,6 +15,36 @@ public sealed partial class UpdateMetadataCommands
await this.UpdateTauriVersion(); await this.UpdateTauriVersion();
} }
private async Task UpdateChangelog(int buildNumber, string appVersion, string buildTime)
{
var pathChangelogs = Path.Combine(Environment.GetAIStudioDirectory(), "wwwroot", "changelog");
var expectedLogFilename = $"v{appVersion}.md";
var expectedLogFilePath = Path.Combine(pathChangelogs, expectedLogFilename);
if(!File.Exists(expectedLogFilePath))
{
Console.WriteLine($"- Error: The changelog file '{expectedLogFilename}' does not exist.");
return;
}
const string CODE_START =
"""
LOGS =
[
""";
var changelogCodePath = Path.Join(Environment.GetAIStudioDirectory(), "Components", "Changelog.Logs.cs");
var changelogCode = await File.ReadAllTextAsync(changelogCodePath, Encoding.UTF8);
var updatedCode =
$"""
{CODE_START}
new ({buildNumber}, "v{appVersion}, build {buildNumber} ({buildTime})", "{expectedLogFilename}"),
""";
changelogCode = changelogCode.Replace(CODE_START, updatedCode);
await File.WriteAllTextAsync(changelogCodePath, changelogCode, Environment.UTF8_NO_BOM);
}
private async Task UpdateProjectCommitHash() private async Task UpdateProjectCommitHash()
{ {
const int COMMIT_HASH_INDEX = 8; const int COMMIT_HASH_INDEX = 8;