Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,35 @@ jobs:
[IO.File]::WriteAllText("dist/$name.zip.sha256", "$hash $name.zip`n")
"archive=dist/$name.zip" >> $env:GITHUB_OUTPUT

- name: Install Inno Setup
shell: pwsh
run: packaging/windows/install-inno.ps1 -Dir "$env:RUNNER_TEMP\inno"

- name: Installer
id: installer
shell: pwsh
env:
VERSION: ${{ needs.release.outputs.version }}
ARCH: ${{ matrix.arch }}
run: |
ISCC.exe /Q "/DAppVersion=$env:VERSION" "/DArch=$env:ARCH" `
packaging/windows/disktree.iss
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$name = "disktree-$env:VERSION-$env:ARCH-windows-setup.exe"
$hash = (Get-FileHash "target/bundle/$name" -Algorithm SHA256).Hash.ToLower()
[IO.File]::WriteAllText("target/bundle/$name.sha256", "$hash $name`n")
"setup=target/bundle/$name" >> $env:GITHUB_OUTPUT

- name: Upload
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.release.outputs.tag }}
ARCHIVE: ${{ steps.package.outputs.archive }}
run: gh release upload "$TAG" "$ARCHIVE" "$ARCHIVE.sha256" --clobber
SETUP: ${{ steps.installer.outputs.setup }}
run: |
gh release upload "$TAG" "$ARCHIVE" "$ARCHIVE.sha256" \
"$SETUP" "$SETUP.sha256" --clobber

publish:
name: Publish
Expand Down
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ On macOS `make install` installs `target/bundle/disktree.app` into
`packaging/macos/` (the `Info.plist` template and the icon's SVG). The bundle
identifier there keys every macOS permission grant; do not change it lightly.

On Windows the release also ships a setup program, compiled by Inno Setup 7
from `packaging/windows/disktree.iss` after `cargo build --release`:
`ISCC.exe /DAppVersion=<version> /DArch=x86_64 packaging\windows\disktree.iss`
writes `target\bundle\disktree-<version>-x86_64-windows-setup.exe`. Its
`AppId` is how upgrades and the uninstaller find an existing install; never
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.
On Windows, where there is no make, run `cargo xtask lint`, `cargo xtask test`
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ NOTARY_PROFILE=<profile> cargo xtask bundle \

### Windows

On Windows 10 or 11, download `disktree-*-x86_64-windows.zip`
(`aarch64-windows` on ARM) from the same release, unpack it anywhere and run
`disktree.exe`. Or build it with Rust 1.97 or newer, from
On Windows 10 or 11, download `disktree-*-x86_64-windows-setup.exe`
(`aarch64-windows` on ARM, Windows 11) from the same release and run it. It
installs for you alone, with no administrator prompt, unless you choose all
users on its first page; it adds disktree to the Start menu and the desktop,
and to **Settings > Apps** to uninstall. A newer setup upgrades in place.

The setup is not signed, so SmartScreen says "Windows protected your PC";
choose **More info**, then **Run anyway**.

To skip installing, download `disktree-*-x86_64-windows.zip` instead, unpack
it anywhere and run `disktree.exe`. Or build it with Rust 1.97 or newer, from
[rustup](https://rustup.rs), and the MSVC toolchain (Visual Studio Build
Tools, C++ workload):

Expand Down
39 changes: 39 additions & 0 deletions packaging/windows/check-setup.ps1
Original file line number Diff line number Diff line change
@@ -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"
67 changes: 67 additions & 0 deletions packaging/windows/disktree.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
; The Windows installer, compiled by Inno Setup 7 from the repo root:
;
; ISCC.exe /DAppVersion=0.11.0 /DArch=x86_64 packaging\windows\disktree.iss
;
; after `cargo build --release`. It writes
; target\bundle\disktree-<version>-<arch>-windows-setup.exe.

#ifndef AppVersion
#error Pass the version: /DAppVersion=<version>
#endif

; One installer per release build, named like the zip. The setup program
; itself is x64 either way; on Arm64 Windows 11 it runs emulated and
; installs the native arm64 binary.
#ifndef Arch
#error Pass the architecture: /DArch=x86_64 or /DArch=aarch64
#elif Arch == "x86_64"
#define Archs "x64compatible"
#elif Arch == "aarch64"
#define Archs "arm64"
#else
#error Arch must be x86_64 or aarch64
#endif

[Setup]
; Upgrades and the uninstaller find an existing install by this id, so it
; must never change; a new one would install disktree a second time.
AppId={{354830A5-B031-45DE-8595-4513BA422E5F}
AppName=disktree
AppVersion={#AppVersion}
AppPublisherURL=https://github.com/tobi/disktree
AppSupportURL=https://github.com/tobi/disktree/issues
AppUpdatesURL=https://github.com/tobi/disktree/releases
; Paths below are relative to the repo root, not to this script.
SourceDir=..\..
OutputDir=target\bundle
OutputBaseFilename=disktree-{#AppVersion}-{#Arch}-windows-setup
SetupIconFile=assets\disktree.ico
UninstallDisplayIcon={app}\disktree.exe
SetupArchitecture=x64
ArchitecturesAllowed={#Archs}
ArchitecturesInstallIn64BitMode={#Archs}
; For the current user by default, with no UAC prompt, as `make install`
; puts it under ~/.local; the first page offers all users instead.
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
DefaultDirName={autopf}\disktree
DisableProgramGroupPage=yes
MinVersion=10.0
WizardStyle=modern
Compression=lzma2/max
SolidCompression=yes

[Tasks]
Name: desktopicon; Description: "{cm:CreateDesktopIcon}"

[Files]
Source: "target\release\disktree.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "README.md"; DestDir: "{app}"
Source: "LICENSE"; DestDir: "{app}"

[Icons]
Name: "{autoprograms}\disktree"; Filename: "{app}\disktree.exe"
Name: "{autodesktop}\disktree"; Filename: "{app}\disktree.exe"; Tasks: desktopicon

[Run]
Filename: "{app}\disktree.exe"; Description: "{cm:LaunchProgram,disktree}"; Flags: postinstall nowait skipifsilent
22 changes: 22 additions & 0 deletions packaging/windows/install-inno.ps1
Original file line number Diff line number Diff line change
@@ -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 }
Loading