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-restore \
|
||||||
--no-build
|
--no-build
|
||||||
|
|
||||||
|
- name: Write Version Text
|
||||||
|
run: |
|
||||||
|
echo "${{ steps.metadata.outputs.version }}" > ./publish/version.txt
|
||||||
|
|
||||||
- name: Write Production Config
|
- name: Write Production Config
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./publish
|
mkdir -p ./publish
|
||||||
|
|||||||
@@ -22,6 +22,20 @@ public class LoginModel : PageModel
|
|||||||
{
|
{
|
||||||
get
|
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()
|
var rawVersion = Assembly.GetEntryAssembly()
|
||||||
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||||
?.InformationalVersion;
|
?.InformationalVersion;
|
||||||
@@ -31,8 +45,9 @@ public class LoginModel : PageModel
|
|||||||
return rawVersion;
|
return rawVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Fallback to dynamic local Git parsing if available
|
||||||
var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd");
|
var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd");
|
||||||
string gitHash = "c6f269e";
|
string gitHash = "024122d";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var baseDir = AppContext.BaseDirectory;
|
var baseDir = AppContext.BaseDirectory;
|
||||||
|
|||||||
@@ -23,6 +23,20 @@ public class IndexModel : PageModel
|
|||||||
{
|
{
|
||||||
get
|
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()
|
var rawVersion = Assembly.GetEntryAssembly()
|
||||||
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||||
?.InformationalVersion;
|
?.InformationalVersion;
|
||||||
@@ -32,8 +46,9 @@ public class IndexModel : PageModel
|
|||||||
return rawVersion;
|
return rawVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Fallback to dynamic local Git parsing if available
|
||||||
var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd");
|
var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd");
|
||||||
string gitHash = "c6f269e";
|
string gitHash = "024122d";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var baseDir = AppContext.BaseDirectory;
|
var baseDir = AppContext.BaseDirectory;
|
||||||
|
|||||||
Reference in New Issue
Block a user