Add release packaging and automatic update support

This commit is contained in:
Elijah 2026-10-03 19:07:11 -07:00
parent 94cd6b984b
commit f971c374f8
20 changed files with 722 additions and 16 deletions

46
packaging/Release.ps1 Normal file
View file

@ -0,0 +1,46 @@
param(
[string]$Version = '',
[ValidateSet('Both','Windows','Linux')][string]$Platform = 'Both',
[string]$Output = 'artifacts/releases',
[string]$PublishRoot = 'artifacts/publish'
)
$ErrorActionPreference = 'Stop'
$root = Split-Path $PSScriptRoot
Set-Location $root
if (!$Version) { [xml]$props = Get-Content Directory.Build.props; $Version = $props.Project.PropertyGroup.Version }
if ($Version -notmatch '^\d+\.\d+\.\d+$') { throw 'Use a stable version such as 1.0.0.' }
$env:DOTNET_CLI_HOME = Join-Path $root '.tools/home'
$env:NUGET_PACKAGES = Join-Path $root '.tools/packages'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
New-Item -ItemType Directory -Force '.tools/feed' | Out-Null
$sdk = Join-Path $root '.tools/dotnet/dotnet.exe'
if (!(Test-Path $sdk)) { $sdk = 'dotnet' }
$localVpk = Join-Path $root '.tools/vpk/vpk.exe'
if (!(Test-Path $localVpk)) {
& dotnet tool restore
if ($LASTEXITCODE) { throw 'Velopack restore failed. Its CLI requires a .NET 10 SDK/runtime.' }
}
function Invoke-Vpk([string[]]$Arguments) {
if (Test-Path $localVpk) { & $localVpk @Arguments } else { & dotnet tool run vpk -- @Arguments }
if ($LASTEXITCODE) { throw 'Velopack packaging failed.' }
}
foreach ($rid in @('win-x64','linux-x64')) {
if ($Platform -eq 'Windows' -and $rid -ne 'win-x64') { continue }
if ($Platform -eq 'Linux' -and $rid -ne 'linux-x64') { continue }
$publish = Join-Path (Join-Path $root $PublishRoot) "$Version/$rid"
$releases = Join-Path $Output $rid
if (Test-Path $publish) { throw "Publish folder already exists: $publish. Use a fresh version or remove that build folder explicitly." }
& $sdk publish src/AstroFrame.Desktop -c Release -r $rid --self-contained true "-p:Version=$Version" -o $publish
if ($LASTEXITCODE) { throw "Publish failed for $rid" }
$argsList = @("[$(if($rid -eq 'win-x64'){'win'}else{'linux'})]", 'pack', '--packId', 'AstroFrame', '--packTitle', 'AstroFrame', '--packAuthors', 'Elijah Kuntz', '--packVersion', $Version, '--packDir', $publish, '--runtime', $rid, '--channel', $rid, '--outputDir', $releases)
if ($rid -eq 'win-x64') { $argsList += @('--mainExe','AstroFrame.Desktop.exe','--icon','src/AstroFrame.Desktop/Assets/astroframe.ico','--noPortable') }
else { $argsList += @('--mainExe','AstroFrame.Desktop','--icon','src/AstroFrame.Desktop/Assets/astroframe.png','--categories','Science;Astronomy;') }
Invoke-Vpk $argsList
if ($rid -eq 'linux-x64') {
Copy-Item -LiteralPath 'packaging/install-linux.sh' -Destination $releases
Copy-Item -LiteralPath 'src/AstroFrame.Desktop/Assets/astroframe.png' -Destination (Join-Path $releases 'astroframe.png')
$bundle = Join-Path $releases "AstroFrame-$Version-linux-x64.zip"
Compress-Archive -LiteralPath @((Join-Path $releases 'AstroFrame-linux-x64.AppImage'),(Join-Path $releases 'install-linux.sh'),(Join-Path $releases 'astroframe.png')) -DestinationPath $bundle -Force
}
}
Write-Output "Release $Version built in $Output. Upload all channel files to one Gitea release; see docs/releases.md."