Files
OpenNest/scripts/Deploy-OpenNest.ps1
T
ajandClaude Opus 5.5 7fe4de4b6d feat(release): ship self-updating Velopack packages on GitHub Releases
Publish-Windows.ps1 now packs the smoke-tested folder with the pinned vpk
CLI (.config/dotnet-tools.json, 1.2.0 to match the Velopack package) into
velopack/: Setup.exe, Portable.zip, the full nupkg, releases.win.json and
RELEASES, checked for the full package and the portable layout and hashed
into OpenNest.vX.Y.Z.velopack.sha256. The release workflow uploads them
with the candidate.

With no feed URL set, installed copies now check GitHub Releases (full
releases only) instead of skipping update checks; a URL in Options still
selects a self-hosted feed. Deploy-OpenNest.ps1 uses the pinned vpk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:52:30 -04:00

77 lines
3.5 KiB
PowerShell

<#
Package a Velopack release of the desktop app and push it to a self-hosted
update feed (a static file server serving the `vpk pack` output). Installed
clients configured with that feed URL (Tools > Options > Auto-update feed URL) pull
and apply updates themselves.
This is separate from scripts/Publish-Windows.ps1 and the GitHub release
process (docs/releasing.md): it targets a privately hosted feed, not a
public GitHub Release, and never embeds that feed's host or path in source.
Bump <Version> in OpenNest/OpenNest.csproj before running this for a new
release.
Examples:
powershell -ExecutionPolicy Bypass -File scripts/Deploy-OpenNest.ps1 `
-FeedHost myhost -FeedUser me -RemoteDataDir ~/docker/opennest-releases/data
#>
Param(
[string]$PublishConfiguration = "Release",
[Parameter(Mandatory)]
[string]$FeedHost,
[string]$FeedUser = "aj",
[Parameter(Mandatory)]
[string]$RemoteDataDir,
# A built opennest-help site/ folder to package instead of the release pinned in help.json.
[string]$HelpDirectory
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ScriptDir = Split-Path -Parent $PSCommandPath
$RepoRoot = if ((Split-Path -Leaf $ScriptDir) -eq 'scripts') { Split-Path -Parent $ScriptDir } else { $ScriptDir }
Write-Host "Repository root: $RepoRoot"
$ProjectPath = Join-Path $RepoRoot 'OpenNest\OpenNest.csproj'
if (-not (Test-Path -LiteralPath $ProjectPath)) { throw "Project not found at: $ProjectPath" }
$csprojContent = Get-Content -LiteralPath $ProjectPath -Raw
if ($csprojContent -notmatch '<Version>(?<v>[\d.]+)</Version>') { throw "Could not find <Version> in $ProjectPath" }
$Version = $Matches.v
Write-Host "Packaging OpenNest v$Version"
# The vpk (Velopack) CLI is pinned in .config/dotnet-tools.json to match the Velopack package
Push-Location $RepoRoot
try { & dotnet tool restore } finally { Pop-Location }
if ($LASTEXITCODE -ne 0) { throw "dotnet tool restore failed" }
$PublishDir = Join-Path $RepoRoot 'OpenNest\bin\publish-tmp'
$ReleasesDir = Join-Path $RepoRoot 'OpenNest\bin\releases'
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
Write-Host "Publishing self-contained build..."
& dotnet publish $ProjectPath -c $PublishConfiguration -r win-x64 --self-contained true -o $PublishDir
if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed with exit code $LASTEXITCODE" }
$helpVersion = & (Join-Path $ScriptDir 'Install-Help.ps1') -Destination (Join-Path $PublishDir 'Help') -HelpDirectory $HelpDirectory
Write-Host "Packaged help $helpVersion"
Write-Host "Packing Velopack release v$Version..."
Push-Location $RepoRoot
try { & dotnet tool run vpk pack -u OpenNest -v $Version -p $PublishDir -e OpenNest.exe -o $ReleasesDir } finally { Pop-Location }
if ($LASTEXITCODE -ne 0) { throw "vpk pack failed with exit code $LASTEXITCODE" }
Write-Host "Pushing release feed to $FeedHost..."
& scp -r "$ReleasesDir\*" "${FeedUser}@${FeedHost}:${RemoteDataDir}/"
if ($LASTEXITCODE -ne 0) { throw "scp failed" }
Write-Host "Deployment complete. Machines already configured with this feed URL will pick up v$Version within 30 minutes."
Write-Host ""
Write-Host "First-time setup on a machine (one-time per machine):"
Write-Host " 1. Copy $ReleasesDir\OpenNest-win-Setup.exe to the machine and run it."
Write-Host " 2. In OpenNest, open Tools > Options and set 'Auto-update feed URL' to"
Write-Host " your feed's base URL (e.g. http://${FeedHost}:<port>), then restart OpenNest."
Write-Host " This value is per-machine and never stored in source control."