diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4807901..039f56e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,6 +117,18 @@ jobs: throw "disktree.exe has no embedded icon" } + # Here rather than only at release time, so a broken installer script + # fails the pull request instead of a release half-way through. + - name: Installer + shell: pwsh + run: | + packaging/windows/install-inno.ps1 -Dir "$env:RUNNER_TEMP\inno" + & "$env:RUNNER_TEMP\inno\ISCC.exe" /Q /DAppVersion=0.0.0 ` + /DArch=x86_64 packaging/windows/disktree.iss + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + packaging/windows/check-setup.ps1 ` + -Setup target/bundle/disktree-0.0.0-x86_64-windows-setup.exe + # The other half of each release: the same tests on the architectures # the release builds for but the jobs above do not run on. other-architectures: @@ -152,3 +164,16 @@ jobs: - name: Test run: cargo xtask test + + # The Arm64 setup, which no other job builds before a release does. + - name: Installer + if: runner.os == 'Windows' + shell: pwsh + run: | + cargo build --release --locked -p disktree-app + packaging/windows/install-inno.ps1 -Dir "$env:RUNNER_TEMP\inno" + & "$env:RUNNER_TEMP\inno\ISCC.exe" /Q /DAppVersion=0.0.0 ` + /DArch=aarch64 packaging/windows/disktree.iss + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + packaging/windows/check-setup.ps1 ` + -Setup target/bundle/disktree-0.0.0-aarch64-windows-setup.exe diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index abd4f5e..6e09399 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -252,23 +252,7 @@ jobs: - name: Install Inno Setup shell: pwsh - # Pinned and checked rather than the runner's own: the two images - # carry different, older versions. - env: - INNO_URL: https://github.com/jrsoftware/issrc/releases/download/is-7_1_0/innosetup-7.1.0-x64.exe - INNO_SHA256: 0362a383ed217d4c4239b5933866dd96d3eb2102737da92f80f6057a4b40df2f - run: | - $setup = "$env:RUNNER_TEMP/innosetup.exe" - $dir = "$env:RUNNER_TEMP/inno" - Invoke-WebRequest $env:INNO_URL -OutFile $setup - $hash = (Get-FileHash $setup -Algorithm SHA256).Hash.ToLower() - if ($hash -ne $env:INNO_SHA256) { - throw "Inno Setup download has SHA256 $hash" - } - Start-Process $setup -Wait -ArgumentList ` - '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/SP-', - '/CURRENTUSER', "/DIR=$dir" - "$dir" >> $env:GITHUB_PATH + run: packaging/windows/install-inno.ps1 -Dir "$env:RUNNER_TEMP\inno" - name: Installer id: installer diff --git a/AGENTS.md b/AGENTS.md index 6b8b8e0..98bc599 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,7 +41,9 @@ from `packaging/windows/disktree.iss` after `cargo build --release`: `ISCC.exe /DAppVersion= /DArch=x86_64 packaging\windows\disktree.iss` writes `target\bundle\disktree--x86_64-windows-setup.exe`. Its `AppId` is how upgrades and the uninstaller find an existing install; never -change it. +change it (`check-setup.ps1` names it too). CI installs the pinned Inno Setup +with `install-inno.ps1`, then compiles the setup on x64 and Arm64 and runs +`check-setup.ps1`, which installs, upgrades and uninstalls it. `cargo xtask lint` is the gate. It must be green before anything is called done, and it must not fix anything: a red local run is the same signal CI gives. diff --git a/packaging/windows/check-setup.ps1 b/packaging/windows/check-setup.ps1 new file mode 100644 index 0000000..4ac8b34 --- /dev/null +++ b/packaging/windows/check-setup.ps1 @@ -0,0 +1,39 @@ +# Install a built setup silently for the current user, check what it put in +# place, install it again over itself as an upgrade, then uninstall and check +# that nothing is left. Exits non-zero on the first thing out of place. +param([Parameter(Mandatory)] [string] $Setup) + +$ErrorActionPreference = 'Stop' +$app = Join-Path $env:LOCALAPPDATA 'Programs\disktree' +$exe = Join-Path $app 'disktree.exe' +$start = Join-Path ([Environment]::GetFolderPath('Programs')) 'disktree.lnk' +$desktop = Join-Path ([Environment]::GetFolderPath('Desktop')) 'disktree.lnk' +# The AppId in disktree.iss, as Inno Setup names its uninstall key. +$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\' + + '{354830A5-B031-45DE-8595-4513BA422E5F}_is1' +$installed = @($exe, $start, $desktop, $key) + +function Invoke-Quiet([string] $Path) { + $p = Start-Process $Path -Wait -PassThru -ArgumentList ` + '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/CURRENTUSER' + if ($p.ExitCode -ne 0) { throw "$Path exited $($p.ExitCode)" } +} + +Invoke-Quiet $Setup +foreach ($path in $installed) { + if (-not (Test-Path $path)) { throw "not installed: $path" } +} +Invoke-Quiet $Setup +$entries = @(Get-ChildItem 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall' | + Where-Object PSChildName -Like '*354830A5-B031-45DE-8595-4513BA422E5F*') +if ($entries.Count -ne 1) { throw "upgrade left $($entries.Count) entries" } + +Invoke-Quiet (Join-Path $app 'unins000.exe') +# The uninstaller hands the last deletions to a copy of itself that outlives +# the process waited on, so give it a moment before looking. +$deadline = (Get-Date).AddSeconds(30) +while ((Test-Path $app) -and (Get-Date) -lt $deadline) { Start-Sleep 1 } +foreach ($path in $installed + $app) { + if (Test-Path $path) { throw "left after uninstall: $path" } +} +Write-Output "setup installs, upgrades and uninstalls cleanly: $Setup" diff --git a/packaging/windows/install-inno.ps1 b/packaging/windows/install-inno.ps1 new file mode 100644 index 0000000..caba171 --- /dev/null +++ b/packaging/windows/install-inno.ps1 @@ -0,0 +1,22 @@ +# Install the pinned Inno Setup into -Dir for the current user and put it on +# the GitHub Actions PATH. Pinned and checked rather than the runner's own: +# the x64 and Arm64 images carry different, older versions. +param([Parameter(Mandatory)] [string] $Dir) + +$ErrorActionPreference = 'Stop' +$url = 'https://github.com/jrsoftware/issrc/releases/download/is-7_1_0/innosetup-7.1.0-x64.exe' +$sha256 = '0362a383ed217d4c4239b5933866dd96d3eb2102737da92f80f6057a4b40df2f' + +$setup = Join-Path ([IO.Path]::GetTempPath()) 'innosetup-7.1.0-x64.exe' +Invoke-WebRequest $url -OutFile $setup +$hash = (Get-FileHash $setup -Algorithm SHA256).Hash.ToLower() +if ($hash -ne $sha256) { throw "Inno Setup download has SHA256 $hash" } + +$p = Start-Process $setup -Wait -PassThru -ArgumentList ` + '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/SP-', + '/CURRENTUSER', "/DIR=$Dir" +if ($p.ExitCode -ne 0) { throw "Inno Setup install exited $($p.ExitCode)" } +if (-not (Test-Path (Join-Path $Dir 'ISCC.exe'))) { + throw "ISCC.exe is missing from $Dir" +} +if ($env:GITHUB_PATH) { $Dir >> $env:GITHUB_PATH }