Files
desktop-edge-win/scripts/build-test-release.ps1
T
Clint Dovholuk 2f7e53f02c Allow registry overrides.conflict.free (#992)
* feat: bump dependencies (NuGet 8 -> 10, NLog 5 -> 6)

* feat: shared IPC data structures for policy state

* feat: registry policy reader with WMI watcher

* feat: monitor service policy enforcement, maintenance window, deferred install

* feat: UI policy state propagation, locks, deferred-install + sentinel UX fix

* feat: ADMX/ADML templates, admin guide, helper script, test runbook

* chore: build tooling, MSI SHA256, version bump, release notes

* more reworking around the adml/admx/md

* build and upload ADMX/ADML admin templates zip

* updates from looking at / testing GPO UI

* missed the prepare-for-tests ps1

* add boms to all ps1's just in case

* update test-run for more vebosity to allow humans to understand

* more updates to release notes

* Fix alignment on "from" label for maintenance window

* Remove arrow pointing to task bar

* Remove unused selection changed stub

* Ensure logical hour value is passed to maintenance window start/end

* Fix invalid URL error not showing - ensure maintenance start/end time errors return correctly

Change variable names

* reworking new-upcoming-releasenotes

* publish admin templates zip + sha256 sidecar to GitHub release, update release note

* add tatooing words

* reword clamping words

---------

Co-authored-by: Christopher Britton <christopher.l.britton@outlook.com>
2026-05-06 09:14:57 -04:00

207 lines
9.5 KiB
PowerShell

# Sample invocations:
# .\build-test-release.ps1 -jsonOnly $true -version 1.1.1
# .\build-test-release.ps1 -jsonOnly $true -version 1.1.1 -stream "dev" -revertGitAfter $true
# .\build-test-release.ps1 -version 2.2.5 -stream "dev" -revertGitAfter $true
# .\build-test-release.ps1 -jsonOnly $true -version 2.2.5 -url https://lnxiskqx49x4.share.zrok.io/local -stream "dev" -revertGitAfter $true
# .\build-test-release.ps1 -version 1.2.3 -url https://lnxiskqx49x4.share.zrok.io/local -stream "dev" -published_at (Get-Date)
# .\build-test-release.ps1 -version 1.2.3 -url https://lnxiskqx49x4.share.zrok.io/local -stream "dev" -published_at "2023-11-02T14:30:00"
# .\build-test-release.ps1 -version 1.2.3 -url https://lnxiskqx49x4.share.zrok.io/local -stream "dev" -published_at "2023-11-02T14:30:00" -Win32Crypto:$true
# .\build-test-release.ps1 -version 1.2.3 -increment -url http://sg4.parkplace-via-dhcp:8000/release-streams/local
param(
[string]$version,
[switch]$increment = $false, # bump the last version tuple before use
[string]$url = "http://localhost:8000/release-streams/local",
[string]$stream = "local",
[datetime]$published_at = (Get-Date).ToUniversalTime(),
[bool]$jsonOnly = $false,
[bool]$revertGitAfter = $true,
[string]$versionQualifier = "",
[switch]$promote = $false, # New parameter for promotion
[bool]$Win32Crypto = $false, #used to specify which ziti edge tunnel version to pull, openssl or win32crypto-based
[int]$FastInterval = 0 # if > 0, bakes ALLOWFASTINTERVAL + <N>s UpdateTimer into the installer for dev testing. 0 = disabled.
)
$newTimestamp = $published_at.ToString("yyyy-MM-ddTHH:mm:ssZ")
if ([string]::IsNullOrEmpty($versionQualifier)) {
if($Win32Crypto) {
$versionQualifier = "-win32crypto"
} else {
$versionQualifier = ""
}
echo "Using versionQualifier: $versionQualifier"
}
# Promote function that copies 'beta.json' to 'latest.json' and updates timestamp
function Promote-Release {
$betaJsonPath = "$repoRoot\release-streams\beta${versionQualifier}.json"
$latestJsonPath = "$repoRoot\release-streams\latest${versionQualifier}.json"
if (Test-Path -Path $betaJsonPath) {
Copy-Item -Force $betaJsonPath $latestJsonPath
Write-Host "Copied '$betaJsonPath' to '$latestJsonPath'."
$latestJsonContent = Get-Content -Path $latestJsonPath -Raw
# Replace the 'published_at' timestamp with the current time
$latestJsonContent = $latestJsonContent -replace '"published_at": "(.*?)"', ('"published_at": "' + $newTimestamp + '"')
# Write the updated content back to the latest.json
Set-Content -Path $latestJsonPath -Value $latestJsonContent
Write-Host "Updated the 'published_at' field in '$latestJsonPath'."
} else {
Write-Host "'$betaJsonPath' not found. Promotion failed." -ForegroundColor Red
}
}
echo ""
$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
$repoRoot = (Resolve-Path "$scriptDirectory\..").Path
$localDir = Join-Path $repoRoot "release-streams\local${versionQualifier}"
# If promote flag is set, invoke the promotion function
if ($promote) {
Promote-Release
}
$version = $version.Trim()
if ($increment -and $version) {
$versionWithoutPrefix = $version -replace '^v', ''
$segments = $versionWithoutPrefix -split '\.'
$segments[-1] = [int]$segments[-1] + 1
$version = ($segments -join '.')
Write-Host -NoNewline "Incremented version to: "
Write-Host -ForegroundColor Green "$version"
}
if (-not $version) {
if (Test-Path -Path "version") {
$version = (Get-Content -Path "version" -Raw).Trim()
Write-Host -NoNewline "Version not supplied. Using version from file and incrementing: "
Write-Host -ForegroundColor Yellow "${version}"
# Increment the last tuple
$versionWithoutPrefix = $version -replace '^v', ''
$segments = $versionWithoutPrefix -split '\.'
$segments[-1] = [int]$segments[-1] + 1
$version = ($segments -join '.')
Write-Host -NoNewline "New Version: "
Write-Host -ForegroundColor Green "$version"
# Check if the 'version' file has changes in git
$gitStatus = git status --porcelain "version"
if (-not $gitStatus) {
# File has not been modified in git, proceed to update it
Set-Content -Path "version" -Value $version -NoNewline
} else {
Write-Host "The version file has changes in git. Update skipped." -ForegroundColor Yellow
}
} else {
Write-Host "Version file not found" -ForegroundColor Red
exit 1
}
} else {
# Regex to match semantic versioning pattern
if ($version -notmatch '^v?\d+(\.\d+){0,3}$') {
Write-Host -ForegroundColor Red "Invalid version format [${version}]. Expected a semantic version (e.g., 1.0.0)."
exit 1
}
Write-Host -NoNewline "Version: "
Write-Host -ForegroundColor Green "$version"
}
Set-Content -Path "version" -Value $version -NoNewline
Write-Host "Updating version file to version: $version" -ForegroundColor Yellow
$outputPath = "$repoRoot\release-streams\${version}.json"
& .\Installer\output-build-json.ps1 -version:$version -url:$url -stream:$stream -published_at:$published_at -outputPath:$outputPath
Copy-Item -Force "$repoRoot\release-streams\${version}.json" "$repoRoot\release-streams\${stream}.json"
echo "json file written to: $repoRoot\release-streams\${stream}.json"
$buildSucceeded = $false
if(! $jsonOnly) {
& .\Installer\build.ps1 -version:$version -url:$url -stream:$stream -published_at:$published_at -jsonOnly:$jsonOnly -revertGitAfter:$revertGitAfter -versionQualifier:$versionQualifier -Win32Crypto:$Win32Crypto -FastInterval:$FastInterval
$exitCode = $LASTEXITCODE
if($exitCode -gt 0) {
Write-Host -ForegroundColor Red "ERROR:"
Write-Host -ForegroundColor Red " - build.ps1 failed!"
Write-Host -ForegroundColor Red " - NOT updating ${localDir}\local.json — the served JSON still points at the previous build."
exit $exitCode
}
mkdir "${localDir}\${version}" -ErrorAction Ignore > $null
Move-Item -Force "$repoRoot/Installer/Output/Ziti Desktop Edge Client-${version}.exe" "$localDir\${version}\Ziti.Desktop.Edge.Client-${version}.exe"
Move-Item -Force "$repoRoot/Installer/Output/Ziti Desktop Edge Client-${version}.exe.sha256" "$localDir\${version}\Ziti.Desktop.Edge.Client-${version}.exe.sha256"
$msiSrc = "$repoRoot/Installer/Output/Ziti Desktop Edge Client-${version}.msi"
if (Test-Path $msiSrc) {
Move-Item -Force $msiSrc "$localDir\${version}\Ziti.Desktop.Edge.Client-${version}.msi"
Move-Item -Force "$repoRoot/Installer/Output/Ziti Desktop Edge Client-${version}.msi.sha256" "$localDir\${version}\Ziti.Desktop.Edge.Client-${version}.msi.sha256"
}
# Confirm the moved EXE actually exists before updating the served JSON.
$producedExe = "$localDir\${version}\Ziti.Desktop.Edge.Client-${version}.exe"
if (-not (Test-Path $producedExe)) {
Write-Host -ForegroundColor Red "ERROR: expected installer missing after move: $producedExe"
Write-Host -ForegroundColor Red " - NOT updating ${localDir}\local.json — the served JSON still points at the previous build."
exit 1
}
$buildSucceeded = $true
Write-Host ""
Write-Host "done."
Write-Host "installer (EXE) exists at $producedExe"
if (Test-Path "$localDir\${version}\Ziti.Desktop.Edge.Client-${version}.msi") {
Write-Host "installer (MSI) exists at $localDir\${version}\Ziti.Desktop.Edge.Client-${version}.msi"
}
}
if($revertGitAfter) {
git checkout DesktopEdge/Properties/AssemblyInfo.cs ZitiUpdateService/Properties/AssemblyInfo.cs Installer/ZitiDesktopEdge.aip
}
# Only update the served local.json when either:
# * this was a jsonOnly run (no build attempted, caller explicitly asked for JSON), or
# * the build + moves completed and the installer EXE is sitting in its expected place.
# Updating unconditionally would leave the test machine fetching a local.json that
# points to a non-existent installer after any build failure.
if ($jsonOnly -or $buildSucceeded) {
& .\Installer\output-build-json.ps1 -version:$version -url:$url -stream:$stream -published_at:$published_at -outputPath:"${localDir}\local.json"
}
$builtConfig = "$repoRoot\ZitiUpdateService\bin\Release\ZitiUpdateService.exe.config"
$builtUpdateTimer = if (Test-Path $builtConfig) {
((Get-Content $builtConfig) | Select-String 'key="UpdateTimer"' | Select-Object -Last 1).ToString().Trim()
} else { "(ZitiUpdateService.exe.config not found at $builtConfig)" }
$summary = @"
============================================================
BUILD SUMMARY
============================================================
version = $version
url = $url
stream = $stream
published_at = $newTimestamp
jsonOnly = $jsonOnly
revertGitAfter = $revertGitAfter
FastInterval = $(if ($FastInterval -gt 0) { "$FastInterval seconds" } else { '(disabled)' })
Win32Crypto = $Win32Crypto
versionQualifier = $(if ($versionQualifier) { $versionQualifier } else { '(none)' })
localDir = $localDir
builtUpdateTimer = $builtUpdateTimer
============================================================
"@
$summaryFile = "$scriptDirectory\build-summary-${version}.txt"
$summary | Set-Content $summaryFile
Write-Host $summary -ForegroundColor Cyan
Write-Host "Start a python server in this location with:"
Write-Host ""
Write-Host " python -m http.server 8000"
Write-Host ""
Write-Host "Set the automatic upgrade url to ${url}/local.json"
Write-Host ""