feat(web): publish version.txt in build pipeline for deterministic live server versioning
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 16s
Validators (Pushes and Pull Requests) / validate-core (push) Successful in 1m46s

This commit is contained in:
2026-07-12 14:05:10 +09:00
parent 024122d310
commit 24ec410f3d
3 changed files with 36 additions and 2 deletions
+4
View File
@@ -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
@@ -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<AssemblyInformationalVersionAttribute>()
?.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;
@@ -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<AssemblyInformationalVersionAttribute>()
?.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;