Files
myGarminApp/packaging/build.ps1
Riaan Doorduin 39ce4e73a0 Windows installer; ship the dashboard template
- packaging/: PyInstaller spec (one folder, windowed, Python included), Inno Setup script
  (per-user install, Start menu, optional desktop icon, WebView2 check), build.ps1, app icon.
- Bundled exe also runs the CLI (output to %LOCALAPPDATA%\myGarmin\cli.log).
- Fix: .gitignore pattern dashboard*.html also hid src/mygarmin/report/dashboard.html, so the
  template was never committed and fresh clones could not build a dashboard. Patterns anchored;
  data file types (*.gpx, *.csv, *.json, *.gz, *.log) ignored too.
- Self-test runs beside an open app (own WebView2 data folder, no single-instance check).
- Neutral example values in a docstring and the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 14:10:05 +02:00

27 lines
1.7 KiB
PowerShell

# Build myGarmin-setup-<version>.exe: PyInstaller (one folder, Python included) -> Inno Setup installer.
# Needs: pip install pyinstaller ; Inno Setup 6 (winget install JRSoftware.InnoSetup).
# usage (from the repo): powershell -ExecutionPolicy Bypass -File packaging\build.ps1
$ErrorActionPreference = 'Stop'
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $here
$version = (Select-String -Path ..\pyproject.toml -Pattern '^version = "(.+)"').Matches[0].Groups[1].Value
$v4 = (($version -split '\.') + @('0', '0', '0'))[0..3] -join ', '
# Windows file version resource for myGarmin.exe
@"
VSVersionInfo(ffi=FixedFileInfo(filevers=($v4), prodvers=($v4)),
kids=[StringFileInfo([StringTable('040904B0', [StringStruct('ProductName', 'myGarmin'), StringStruct('FileDescription', 'myGarmin activity and health logbook'),
StringStruct('FileVersion', '$version'), StringStruct('ProductVersion', '$version'), StringStruct('LegalCopyright', 'MIT licence')])]),
VarFileInfo([VarStruct('Translation', [1033, 1200])])])
"@ | Out-File -Encoding utf8 version_info.txt
python -m PyInstaller --noconfirm --clean --distpath ..\build\dist --workpath ..\build\work myGarmin.spec
if ($LASTEXITCODE) { throw 'PyInstaller failed' }
$iscc = @("$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe", "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", "$env:ProgramFiles\Inno Setup 6\ISCC.exe") |
Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $iscc) { throw 'Inno Setup 6 not found (winget install JRSoftware.InnoSetup)' }
& $iscc "/DAppVersion=$version" myGarmin.iss
if ($LASTEXITCODE) { throw 'Inno Setup failed' }
Get-Item ..\build\installer\*.exe | Select-Object Name, @{n='MB'; e={[math]::Round($_.Length / 1MB, 1)}}