Files
Garage-SDKs/garage_updates/windows_installer/build_installer.bat
T
ImBenjiandClaude Opus 5.5 d3b232f0ee feat(garage_updates): an auto updater for garage apps
Asks Garage for the newest release of a project, downloads it with resume,
checks the sha256, installs it beside the old one and restarts into it.
Splash on garage_ui, a native stub and a first time installer for windows,
bundle swap on mac, the system installer on android. No-op on web.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KHotisA4hV2xmuZsHTksFX
2026-10-12 06:37:02 +01:00

83 lines
3.4 KiB
Batchfile

@echo off
setlocal
rem builds "<AppName>-Setup.exe" for one app. needs cmake and visual studio's
rem c++ tools, the same things flutter build windows needs.
rem
rem build_installer.bat --name "Garage Stash" --id net.imbenji.stash ^
rem --project <garage project id> --exe garage_stash.exe ^
rem --icon C:\path\app_icon.ico
rem
rem optional:
rem --api <url> where the update check goes (default pay.imbenji.net/api)
rem --publisher "<name>" shown in Installed apps
rem --default me^|everyone which one is ticked to begin with (default me)
rem --hide-choice dont ask, go with the default
rem --desktop a desktop shortcut as well
rem --arch x64^|arm64 default x64
rem --out <folder> where the exe is put (default: the folder youre in)
set "HERE=%~dp0"
set "NAME="
set "ID="
set "PROJECT="
set "EXE="
set "ICON="
set "API=https://pay.imbenji.net/api"
set "PUBLISHER="
set "LOCATION=me"
set "CHOICE=ON"
set "DESKTOP=OFF"
set "ARCH=x64"
set "OUT=%CD%"
:args
if "%~1"=="" goto run
if /i "%~1"=="--name" ( set "NAME=%~2" & shift & shift & goto args )
if /i "%~1"=="--id" ( set "ID=%~2" & shift & shift & goto args )
if /i "%~1"=="--project" ( set "PROJECT=%~2" & shift & shift & goto args )
if /i "%~1"=="--exe" ( set "EXE=%~2" & shift & shift & goto args )
if /i "%~1"=="--icon" ( set "ICON=%~f2" & shift & shift & goto args )
if /i "%~1"=="--api" ( set "API=%~2" & shift & shift & goto args )
if /i "%~1"=="--publisher" ( set "PUBLISHER=%~2" & shift & shift & goto args )
if /i "%~1"=="--default" ( set "LOCATION=%~2" & shift & shift & goto args )
if /i "%~1"=="--arch" ( set "ARCH=%~2" & shift & shift & goto args )
if /i "%~1"=="--out" ( set "OUT=%~f2" & shift & shift & goto args )
if /i "%~1"=="--hide-choice" ( set "CHOICE=OFF" & shift & goto args )
if /i "%~1"=="--desktop" ( set "DESKTOP=ON" & shift & goto args )
echo build_installer: dont know what "%~1" is
exit /b 2
:run
if "%NAME%"=="" ( echo build_installer: --name is needed & exit /b 2 )
if "%ID%"=="" ( echo build_installer: --id is needed & exit /b 2 )
if "%PROJECT%"=="" ( echo build_installer: --project is needed & exit /b 2 )
if "%EXE%"=="" ( echo build_installer: --exe is needed & exit /b 2 )
set "VSARCH=x64"
if /i "%ARCH%"=="arm64" set "VSARCH=ARM64"
rem one build folder per app and arch, so two apps dont share a cache
set "BUILD=%HERE%build\%ID%-%ARCH%"
rem cmake wants forward slashes in a path it is going to paste in to an .rc
if defined ICON set "ICON=%ICON:\=/%"
cmake -S "%HERE%." -B "%BUILD%" -A %VSARCH% ^
"-DGARAGE_APP_NAME=%NAME%" "-DGARAGE_APP_ID=%ID%" "-DGARAGE_PROJECT_ID=%PROJECT%" ^
"-DGARAGE_EXE_NAME=%EXE%" "-DGARAGE_API_BASE=%API%" "-DGARAGE_PUBLISHER=%PUBLISHER%" ^
"-DGARAGE_ICON=%ICON%" "-DGARAGE_DEFAULT_LOCATION=%LOCATION%" ^
-DGARAGE_SHOW_CHOICE=%CHOICE% -DGARAGE_DESKTOP_SHORTCUT=%DESKTOP%
if errorlevel 1 ( echo build_installer: cmake couldnt set the build up & exit /b 1 )
cmake --build "%BUILD%" --config Release
if errorlevel 1 ( echo build_installer: the build failed & exit /b 1 )
if not exist "%OUT%" mkdir "%OUT%"
copy /y "%BUILD%\Release\*-Setup.exe" "%OUT%\" >nul
if errorlevel 1 ( echo build_installer: built, but couldnt copy the exe out of %BUILD%\Release & exit /b 1 )
echo.
echo the installer is in %OUT%
endlocal