feat(web): publish version.txt in build pipeline for deterministic live server versioning
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user