From 90465b1dce261865fa3146acc2d7e7a91c601c43 Mon Sep 17 00:00:00 2001 From: Abdulwahb Isam Date: Fri, 16 Oct 2026 08:51:45 +0300 Subject: [PATCH 1/4] disktree: feat: add an Inno Setup script for a Windows installer packaging/windows/disktree.iss builds disktree---windows- setup.exe from the release binary. It installs for the current user with no UAC prompt by default (the first page offers all users), adds a Start menu entry, a desktop shortcut and an uninstaller in Settings > Apps, and upgrades in place, keyed by a fixed AppId. x86_64 and aarch64 each get their own setup. Verified with Inno Setup 7.1.0 on Windows 11 x64: ISCC compiles cleanly; leaving out /DArch or passing an unknown one aborts the compile; a silent /CURRENTUSER install creates the exe, both shortcuts and the uninstall entry, and disktree launches; a second install upgrades with one uninstall entry; unins000.exe removes all of it including the install folder. --- packaging/windows/disktree.iss | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 packaging/windows/disktree.iss diff --git a/packaging/windows/disktree.iss b/packaging/windows/disktree.iss new file mode 100644 index 00000000..503458c2 --- /dev/null +++ b/packaging/windows/disktree.iss @@ -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---windows-setup.exe. + +#ifndef AppVersion + #error Pass the version: /DAppVersion= +#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 From c49119aef36ed872fb6c0fd33d93e8fb4c35e759 Mon Sep 17 00:00:00 2001 From: Abdulwahb Isam Date: Fri, 16 Oct 2026 08:51:46 +0300 Subject: [PATCH 2/4] disktree: feat: publish the Windows setup with each release The windows release job installs Inno Setup 7.1.0 from its GitHub release, checked against a pinned SHA256 (the runners carry 6.7.1 and 6.6.1), compiles packaging/windows/disktree.iss for the job's architecture, and uploads the setup with a sha256 file in the same format as the zip's. Verified: the pinned hash is of the downloaded installer, whose Authenticode signature is valid; the workflow parses. Not yet run in Actions. --- .github/workflows/release.yml | 40 ++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04712f50..abd4f5e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -250,13 +250,51 @@ 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 + # 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 + + - 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 From 7ee70c5846f1f499cecf3531e46b2ae24eefefed Mon Sep 17 00:00:00 2001 From: Abdulwahb Isam Date: Fri, 16 Oct 2026 08:51:46 +0300 Subject: [PATCH 3/4] disktree: docs: document the Windows setup README: the setup is the default Windows download, per-user unless all users is chosen, unsigned so SmartScreen needs More info then Run anyway; the zip remains. AGENTS.md: how to compile the setup locally, and that its AppId must never change. Verified: cargo xtask lint is green. --- AGENTS.md | 7 +++++++ README.md | 14 +++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a567ce80..6b8b8e03 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,13 @@ 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= /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. + `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` diff --git a/README.md b/README.md index 80442695..314eed93 100644 --- a/README.md +++ b/README.md @@ -110,9 +110,17 @@ NOTARY_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): From c8a9336acb8d991cb44fc657d8ddc44643acfe65 Mon Sep 17 00:00:00 2001 From: Abdulwahb Isam Date: Fri, 16 Oct 2026 09:02:06 +0300 Subject: [PATCH 4/4] disktree: test: build and check the Windows setup on every pull request CI compiled nothing of the installer, so a broken disktree.iss would first fail inside a release, after its draft exists, and the Arm64 setup had never been built at all. The Windows job now compiles the x64 setup and the Windows aarch64 job the Arm64 one; both run check-setup.ps1, which installs it silently for the current user, checks the exe, Start menu and desktop shortcuts and the uninstall entry, installs again as an upgrade (one entry left), uninstalls and checks nothing remains. install-inno.ps1 takes over the pinned, hash-checked Inno Setup install from release.yml and now fails on a non-zero installer exit or a missing ISCC.exe instead of leaving the next step to report it. Verified locally on Windows 11 x64: both scripts pass, and the CI Installer step body, run as written, compiles a 0.0.0 setup and reports "setup installs, upgrades and uninstalls cleanly". Upgrading while disktree runs closes it through Restart Manager without a reboot. The Arm64 job has not run yet. --- .github/workflows/ci.yml | 25 +++++++++++++++++++ .github/workflows/release.yml | 18 +------------- AGENTS.md | 4 ++- packaging/windows/check-setup.ps1 | 39 ++++++++++++++++++++++++++++++ packaging/windows/install-inno.ps1 | 22 +++++++++++++++++ 5 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 packaging/windows/check-setup.ps1 create mode 100644 packaging/windows/install-inno.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48079012..039f56e7 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 abd4f5e6..6e093993 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 6b8b8e03..98bc599f 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 00000000..4ac8b34e --- /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 00000000..caba1718 --- /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 }