From 24ec410f3d37770f44835a79c7572815aada2e38 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sun, 12 Jul 2026 14:05:10 +0900 Subject: [PATCH] feat(web): publish version.txt in build pipeline for deterministic live server versioning --- .gitea/workflows/prepare-release.yml | 4 ++++ .../Pages/Account/Login.cshtml.cs | 17 ++++++++++++++++- .../Pages/Admin/Dashboard/Index.cshtml.cs | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/prepare-release.yml b/.gitea/workflows/prepare-release.yml index 6b9a99d0..95feb200 100644 --- a/.gitea/workflows/prepare-release.yml +++ b/.gitea/workflows/prepare-release.yml @@ -96,6 +96,10 @@ jobs: --no-restore \ --no-build + - name: Write Version Text + run: | + echo "${{ steps.metadata.outputs.version }}" > ./publish/version.txt + - name: Write Production Config run: | mkdir -p ./publish diff --git a/src/dotnet/QuantEngine.Web/Pages/Account/Login.cshtml.cs b/src/dotnet/QuantEngine.Web/Pages/Account/Login.cshtml.cs index 58f4466e..dbfeb8d4 100644 --- a/src/dotnet/QuantEngine.Web/Pages/Account/Login.cshtml.cs +++ b/src/dotnet/QuantEngine.Web/Pages/Account/Login.cshtml.cs @@ -22,6 +22,20 @@ public class LoginModel : PageModel { get { + // 1. Try reading version.txt from application base directory + try + { + var txtPath = Path.Combine(AppContext.BaseDirectory, "version.txt"); + if (System.IO.File.Exists(txtPath)) + { + var txtVersion = System.IO.File.ReadAllText(txtPath).Trim(); + if (!string.IsNullOrEmpty(txtVersion)) + return txtVersion; + } + } + catch {} + + // 2. Try reading raw assembly version var rawVersion = Assembly.GetEntryAssembly() ?.GetCustomAttribute() ?.InformationalVersion; @@ -31,8 +45,9 @@ public class LoginModel : PageModel return rawVersion; } + // 3. Fallback to dynamic local Git parsing if available var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd"); - string gitHash = "c6f269e"; + string gitHash = "024122d"; try { var baseDir = AppContext.BaseDirectory; diff --git a/src/dotnet/QuantEngine.Web/Pages/Admin/Dashboard/Index.cshtml.cs b/src/dotnet/QuantEngine.Web/Pages/Admin/Dashboard/Index.cshtml.cs index 1a511f6c..f6ae4314 100644 --- a/src/dotnet/QuantEngine.Web/Pages/Admin/Dashboard/Index.cshtml.cs +++ b/src/dotnet/QuantEngine.Web/Pages/Admin/Dashboard/Index.cshtml.cs @@ -23,6 +23,20 @@ public class IndexModel : PageModel { get { + // 1. Try reading version.txt from application base directory + try + { + var txtPath = Path.Combine(AppContext.BaseDirectory, "version.txt"); + if (System.IO.File.Exists(txtPath)) + { + var txtVersion = System.IO.File.ReadAllText(txtPath).Trim(); + if (!string.IsNullOrEmpty(txtVersion)) + return txtVersion; + } + } + catch {} + + // 2. Try reading raw assembly version var rawVersion = Assembly.GetEntryAssembly() ?.GetCustomAttribute() ?.InformationalVersion; @@ -32,8 +46,9 @@ public class IndexModel : PageModel return rawVersion; } + // 3. Fallback to dynamic local Git parsing if available var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd"); - string gitHash = "c6f269e"; + string gitHash = "024122d"; try { var baseDir = AppContext.BaseDirectory;