fix: parse version.json instead of version.txt in Program.cs
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s

- CI/CD generates version.json (JSON format) but Program.cs was parsing version.txt
- Update version loading to read from version.json
- Add error handling for JSON parsing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 09:57:01 +09:00
parent 821b73fe01
commit 541b04cf3d
+13 -8
View File
@@ -85,16 +85,21 @@ builder.Services.AddApplication();
// Register version info // Register version info
var versionInfo = new VersionInfo(); var versionInfo = new VersionInfo();
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.txt"); var versionJsonPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.json");
if (File.Exists(versionFilePath)) if (File.Exists(versionJsonPath))
{ {
var lines = File.ReadAllLines(versionFilePath); try
foreach (var line in lines)
{ {
if (line.StartsWith("Version:")) var json = System.Text.Json.JsonDocument.Parse(File.ReadAllText(versionJsonPath));
versionInfo.Version = line.Substring("Version:".Length).Trim(); var root = json.RootElement;
else if (line.StartsWith("Built:")) if (root.TryGetProperty("version", out var versionProp))
versionInfo.Built = line.Substring("Built:".Length).Trim(); versionInfo.Version = versionProp.GetString() ?? "unknown";
if (root.TryGetProperty("built", out var builtProp))
versionInfo.Built = builtProp.GetString() ?? "unknown";
}
catch (Exception ex)
{
Console.WriteLine($"Warning: Failed to parse version.json: {ex.Message}");
} }
} }
builder.Services.AddSingleton(versionInfo); builder.Services.AddSingleton(versionInfo);