From 290538ef1dffc163d98095ea1bf5d188ff5ba056 Mon Sep 17 00:00:00 2001 From: prestoncraw Date: Fri, 21 Aug 2026 10:56:47 -0400 Subject: [PATCH 1/2] add UI versioning --- Jenkinsfile | 2 + Scripts/PackageVersioning.ps1 | 86 +++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 Scripts/PackageVersioning.ps1 diff --git a/Jenkinsfile b/Jenkinsfile index d1b7f3f3..7930cd77 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -122,7 +122,9 @@ pipeline { env.GIT_COMMIT = bat(script: '@git rev-parse HEAD', returnStdout: true).trim() } powershell "powershell.exe -File .\\Scripts\\Versioning.ps1 -VersionFile './Scripts/PQBrowser.version' -Commit false" + powershell "powershell.exe -File .\\Scripts\\PackageVersioning.ps1 -VersionFile './PQBrowser/package.json'" bat(script: "@git add Scripts/PQBrowser.version") + bat(script: "@git add PQBrowser/package.json") bat(script: "git diff --cached --quiet || git commit -m \"Updated Version Number\"") } } diff --git a/Scripts/PackageVersioning.ps1 b/Scripts/PackageVersioning.ps1 new file mode 100644 index 00000000..c0c20631 --- /dev/null +++ b/Scripts/PackageVersioning.ps1 @@ -0,0 +1,86 @@ +param( + [string]$VersionFile +) + +#Compare Versions +function CompareVersions { + param( + [string]$Version1, + [string]$Version2 + ) + + $array1 = $Version1.Split(".") + $array2 = $Version2.Split(".") + + $i = 0 + while ($i -lt [Math]::Max($array1.Count, $array2.Count)) { + if ($i -ge $array1.Count) { + $v1 = 0 + } else { + $v1 = [int]$array1[$i] + } + if ($i -ge $array2.Count) { + $v2 = 0 + } else { + $v2 = [int]$array2[$i] + } + if ($v1 -gt $v2) { + return 1 + } + if ($v2 -gt $v1) { + return -1 + } + $i++ + } + return 0 +} + +#Increment Version +function IncrementVersion { + param( + [string]$prevVersion + ) + $array = $prevVersion.Split(".") + $array[$array.Count - 1] = [int]$array[$array.Count - 1] + 1 + return $array -join '.' +} + +#Get Latest Version on Github +git fetch origin master:refs/remotes/origin/master +$commit = git rev-parse origin/master +$tag = git describe --tags --abbrev=0 $commit + +if ([String]::IsNullOrEmpty($tag)) { + Write-Host "No previous tag found" + $tag = "v3.0.0" +} + +$tag = $tag.TrimStart("v") + +Write-Host "Last Published Version Found: $tag" + + +# Get Current Version +$currentVersion = $((Get-Content -Path $VersionFile | ConvertFrom-Json).version) +Write-Host "Current Version in Repository: $currentVersion" + +# Check if Update is needed +if ((CompareVersions -Version1 $currentVersion -Version2 $tag) -gt 0) { + Write-Host "No Version update neccesarry" + return; +} + +# Update Version +$updatedVersion = IncrementVersion -prevVersion $tag + +Write-Host "Updating to $updatedVersion" + +$content = [System.IO.File]::ReadAllText($VersionFile) +$versionPattern = [regex]'(?m)(^\s*"version"\s*:\s*")[^"]+("\s*,)' +$content = $versionPattern.Replace($content, { + param($match) + return $match.Groups[1].Value + $updatedVersion + $match.Groups[2].Value +}, 1) + +$utf8WithoutBom = New-Object System.Text.UTF8Encoding($false) +[System.IO.File]::WriteAllText($VersionFile, $content, $utf8WithoutBom) From e56887bcb424140a4efd52bcfae551ce872c1745 Mon Sep 17 00:00:00 2001 From: prestoncraw Date: Tue, 25 Aug 2026 16:18:14 -0400 Subject: [PATCH 2/2] Remove UIVersion from logic to bust cache --- PQBrowser/PQBrowser.csproj | 6 +----- PQBrowser/Startup.cs | 5 ----- PQBrowser/Views/Home/Index.cshtml | 6 +++++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/PQBrowser/PQBrowser.csproj b/PQBrowser/PQBrowser.csproj index f31d6686..dc9e5ec6 100644 --- a/PQBrowser/PQBrowser.csproj +++ b/PQBrowser/PQBrowser.csproj @@ -84,11 +84,7 @@ PreserveNewest - - PreserveNewest - PreserveNewest - - + diff --git a/PQBrowser/Startup.cs b/PQBrowser/Startup.cs index 2e77036c..7637743e 100644 --- a/PQBrowser/Startup.cs +++ b/PQBrowser/Startup.cs @@ -42,7 +42,6 @@ using PQBrowser.Security; using System; using System.IO; -using System.Text.Json; namespace PQBrowser; public class Startup @@ -52,9 +51,6 @@ public Startup(IConfiguration configuration, IWebHostEnvironment env) SetupTempPath(); Configuration = configuration; Env = env; - - using JsonDocument package = JsonDocument.Parse(File.ReadAllText(Path.Combine(env.ContentRootPath, "package.json"))); - UIVersion = package.RootElement.GetProperty("version").GetString()!; } public static class Policies @@ -65,7 +61,6 @@ public static class Policies public IWebHostEnvironment Env { get; set; } public IConfiguration Configuration { get; } - public static string UIVersion { get; private set; } = ""; public void ConfigureServices(IServiceCollection services) { diff --git a/PQBrowser/Views/Home/Index.cshtml b/PQBrowser/Views/Home/Index.cshtml index 1614ff15..72ece45f 100644 --- a/PQBrowser/Views/Home/Index.cshtml +++ b/PQBrowser/Views/Home/Index.cshtml @@ -22,6 +22,7 @@ //*******************************************************************************************************@ @using Gemstone.Data @using Gemstone.Configuration; +@using Gemstone.Reflection @using Microsoft.AspNetCore.Antiforgery @using Microsoft.AspNetCore.Authentication.Cookies @using Microsoft.Extensions.Options @@ -40,6 +41,9 @@ @{ Layout = ""; + Version assemblyVersionInfo = AssemblyInfo.EntryAssembly.Version; + string applicationVersion = assemblyVersionInfo.Major + "." + assemblyVersionInfo.Minor + "." + assemblyVersionInfo.Build; + try { using (AdoDataConnection connection = new AdoDataConnection(Settings.Default)) { @@ -123,6 +127,6 @@ - +