Skip to content

Commit 2816ec8

Browse files
committed
Add hotfix build support
1 parent 1bca39e commit 2816ec8

5 files changed

Lines changed: 118 additions & 2 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ on:
2222
required: false
2323
default: false
2424
type: boolean
25+
hotfix:
26+
description: Optional hotfix stamp (e.g. 1 or hotfix.1 → {manifest}-hotfix.1). Leave empty for manifest version.
27+
required: false
28+
default: ""
29+
type: string
2530

2631
concurrency:
2732
group: ${{ github.workflow }}-${{ github.ref }}
@@ -110,12 +115,34 @@ jobs:
110115
PUBLISH_RELEASE: ${{ inputs.publish_release }}
111116
OVERRIDE_EXISTING_RELEASE: ${{ inputs.override_existing_release }}
112117
ARCHES: ${{ steps.matrix.outputs.arches }}
118+
HOTFIX: ${{ inputs.hotfix }}
113119
run: |
120+
. .\build\common.ps1
121+
$null = Initialize-NvmBuildContext
122+
# Always read base from on-disk manifest (ignore any prior NVM_CLI_VERSION).
123+
$manifestPath = Get-NvmCliManifestPath
124+
$baseVersion = [string](Get-Content -LiteralPath $manifestPath -Raw -Encoding UTF8 | ConvertFrom-Json).version
125+
if ([string]::IsNullOrWhiteSpace($baseVersion)) {
126+
throw "CLI manifest does not define version: $manifestPath"
127+
}
128+
$effective = Resolve-NvmHotfixVersion -BaseVersion $baseVersion -Hotfix $env:HOTFIX
129+
if ($effective -ne $baseVersion) {
130+
Write-Host ("Hotfix stamp -> {0} (base {1})" -f $effective, $baseVersion)
131+
}
132+
else {
133+
Write-Host ("Release version -> {0} (no hotfix input)" -f $effective)
134+
}
135+
[Environment]::SetEnvironmentVariable("NVM_CLI_VERSION", $effective, "Process")
136+
if (-not [string]::IsNullOrWhiteSpace($env:GITHUB_ENV)) {
137+
Add-Content -LiteralPath $env:GITHUB_ENV -Value "NVM_CLI_VERSION=$effective"
138+
}
139+
114140
$archList = @($env:ARCHES -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
115141
$gateArgs = @{
116142
Mode = "Gate"
117143
Architectures = $archList
118144
Enabled = ($env:PUBLISH_RELEASE -eq "true")
145+
Version = $effective
119146
}
120147
if ($env:OVERRIDE_EXISTING_RELEASE -eq "true") {
121148
$gateArgs["OverrideExisting"] = $true
@@ -135,6 +162,7 @@ jobs:
135162
env:
136163
GOBIN: ${{ github.workspace }}\go-bin
137164
ARCHITECTURE: ${{ matrix.architecture }}
165+
NVM_CLI_VERSION: ${{ needs.prepare.outputs.version }}
138166

139167
steps:
140168
- name: Check GitHub App secrets
@@ -210,6 +238,21 @@ jobs:
210238
throw "git submodule update failed with exit code $LASTEXITCODE"
211239
}
212240
241+
- name: Stamp CLI manifest version (hotfix / gate)
242+
env:
243+
EFFECTIVE_VERSION: ${{ needs.prepare.outputs.version }}
244+
run: |
245+
if ([string]::IsNullOrWhiteSpace($env:EFFECTIVE_VERSION)) {
246+
throw "prepare.outputs.version empty (cannot stamp cli/src/manifest.json)"
247+
}
248+
. .\build\common.ps1
249+
$null = Initialize-NvmBuildContext
250+
$base = (Get-Content -LiteralPath (Get-NvmCliManifestPath) -Raw -Encoding UTF8 | ConvertFrom-Json).version
251+
Set-NvmCliManifestVersion -Version $env:EFFECTIVE_VERSION
252+
if ($env:EFFECTIVE_VERSION -ne [string]$base) {
253+
Write-Host ("Hotfix stamp -> {0} (base {1})" -f $env:EFFECTIVE_VERSION, $base)
254+
}
255+
213256
- name: Set up Go
214257
uses: actions/setup-go@v7
215258
with:

‎build/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ Workflow: [Release Community Build](../.github/workflows/release.yml) (`workflow
5151
| `architecture` | `both` | `amd64`, `arm64`, or both |
5252
| `publish_release` | true | Draft → upload assets → publish |
5353
| `override_existing_release` | false | Replace setup.exe **and** sync.exe on existing tag |
54+
| `hotfix` | _(empty)_ | Optional stamp: `1` or `hotfix.1` → `{manifest}-hotfix.N` without committing `cli/src/manifest.json` |
5455

5556
GitHub Release assets per architecture:
5657

5758
- `nvm---setup.exe` — Inno Setup installer
5859
- `nvm---sync.exe` — prebuilt sync for `-DownloadSync`
5960

60-
Tag = `v` + `cli/src/manifest.json` `version`.
61+
Tag = `v` + effective version (`cli/src/manifest.json` version, plus optional `hotfix` stamp). Runner patches manifest before CLI/Inno build so embeds and `AppVersion` match. Inno `VersionInfoVersion` already maps `-hotfix.N` → fourth numeric field (`2.0.1-hotfix.1` → `2.0.1.1`).
6162

6263
### WinGet
6364

‎build/common.ps1‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ function Get-NvmCliManifestPath {
4343
}
4444

4545
function Get-NvmCliVersion {
46+
# GHA / packaging: set NVM_CLI_VERSION (e.g. prepare.outputs.version with hotfix stamp).
47+
$fromEnv = [Environment]::GetEnvironmentVariable("NVM_CLI_VERSION")
48+
if (-not [string]::IsNullOrWhiteSpace($fromEnv)) {
49+
return $fromEnv.Trim()
50+
}
4651
$manifestPath = Get-NvmCliManifestPath
4752
if (-not (Test-Path -LiteralPath $manifestPath -PathType Leaf)) {
4853
throw "CLI manifest not found: $manifestPath"
@@ -55,6 +60,67 @@ function Get-NvmCliVersion {
5560
return $version
5661
}
5762

63+
function Resolve-NvmHotfixVersion {
64+
param(
65+
[Parameter(Mandatory = $true)]
66+
[string]$BaseVersion,
67+
[string]$Hotfix = ""
68+
)
69+
70+
$base = $BaseVersion.Trim()
71+
if ([string]::IsNullOrWhiteSpace($base)) {
72+
throw "Resolve-NvmHotfixVersion: BaseVersion is empty"
73+
}
74+
75+
$raw = if ($null -eq $Hotfix) { "" } else { $Hotfix.Trim() }
76+
if ([string]::IsNullOrWhiteSpace($raw)) {
77+
return $base
78+
}
79+
80+
$suffix = $null
81+
if ($raw -match '^\d+$') {
82+
$suffix = "hotfix.$raw"
83+
}
84+
elseif ($raw -match '^(?i)hotfix\.(\d+)$') {
85+
$suffix = "hotfix.$($Matches[1])"
86+
}
87+
else {
88+
throw @"
89+
Resolve-NvmHotfixVersion: invalid hotfix input '$raw'.
90+
Use empty (no override), a digit run (e.g. 1 -> -hotfix.1), or hotfix.N (e.g. hotfix.1).
91+
"@
92+
}
93+
94+
return "{0}-{1}" -f $base, $suffix
95+
}
96+
97+
function Set-NvmCliManifestVersion {
98+
param(
99+
[Parameter(Mandatory = $true)]
100+
[string]$Version
101+
)
102+
103+
$ver = $Version.Trim()
104+
if ([string]::IsNullOrWhiteSpace($ver)) {
105+
throw "Set-NvmCliManifestVersion: Version is empty"
106+
}
107+
108+
$manifestPath = Get-NvmCliManifestPath
109+
if (-not (Test-Path -LiteralPath $manifestPath -PathType Leaf)) {
110+
throw "CLI manifest not found: $manifestPath"
111+
}
112+
113+
$manifest = Get-Content -LiteralPath $manifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
114+
$before = [string]$manifest.version
115+
$manifest.version = $ver
116+
117+
$json = $manifest | ConvertTo-Json -Depth 30
118+
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
119+
[System.IO.File]::WriteAllText($manifestPath, ($json.TrimEnd() + "`n"), $utf8NoBom)
120+
121+
Write-Host ("CLI manifest version -> {0} (was {1}) [{2}]" -f $ver, $before, $manifestPath)
122+
}
123+
58124
function Initialize-NvmBuildContext {
59125
param([string]$BinRoot = "")
60126

‎build/steps/Build-Installer.ps1‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ if (-not (Test-Path -LiteralPath $bat -PathType Leaf)) {
2323
}
2424

2525
$manifest = Get-Content -LiteralPath $manifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
26-
$version = [string]$manifest.version
26+
# Prefer gate/hotfix stamp (NVM_CLI_VERSION / patched manifest) over raw file alone.
27+
$version = $ctx.CliVersion
2728
$aumid = [string]$manifest.appUserModelId
2829
$appId = [string]$manifest.appId
2930
if ([string]::IsNullOrWhiteSpace($version) -or [string]::IsNullOrWhiteSpace($aumid) -or [string]::IsNullOrWhiteSpace($appId)) {
3031
throw "installer manifest values (version, appUserModelId, appId) are required"
3132
}
3233

34+
Write-Host "Installer version -> $version"
35+
3336
# Inno copies bin/.sync/* only when sync.exe exists; keep dir present, no DLLs.
3437
New-Item -ItemType Directory -Force -Path (Join-Path $ctx.BinRoot ".sync") | Out-Null
3538

‎build/steps/Publish-GitHubRelease.ps1‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ Architectures: $noteArches.
459459
460460
Assets per arch: Inno Setup installer (``*-setup.exe``) and prebuilt ``sync.exe`` (``*-sync.exe``) for public ``-DownloadSync`` builds.
461461
"@
462+
if ($Version -match '(?i)-hotfix\.\d+') {
463+
$intro += "`n`nHotfix stamp applied at build time via the Community Release ``hotfix`` workflow input (manifest base left unchanged in git)."
464+
}
462465
$commits = Get-NvmReleaseCommitSummarySection -Tag $Tag -HeadRef $headRef
463466
$footer = Get-NvmReleaseNotesFooter
464467
return ($intro.TrimEnd() + "`n`n" + $commits.TrimEnd() + $footer)

0 commit comments

Comments
 (0)