@echo off setlocal EnableExtensions cd /d "%~dp0" echo Bumping build number... call :bump_build if errorlevel 1 exit /b 1 REM Full version = CurrentVersion.BuildNumber from versioninfo.json (e.g. 3.8.2.4) set "VER=" for /f "usebackq delims=" %%v in (`powershell -NoProfile -Command "(Get-Content -Raw 'versioninfo.json' | ConvertFrom-Json).StringFileInfo.FileVersion"`) do set "VER=%%v" if not defined VER ( echo Failed to read FileVersion from versioninfo.json exit /b 1 ) set "OUT_GUI=Navis-%VER%.exe" set "OUT_CLI=vpnclient-%VER%.exe" set "DIST=dist\navis-release" echo Building Navis %VER% for Windows... echo Generating Windows icon resources... go run ./tools/mkico if errorlevel 1 exit /b 1 where goversioninfo >nul 2>&1 if errorlevel 1 ( go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest ) goversioninfo -64 -icon assets\navis.ico -manifest assets\app.manifest -o cmd\vpnapp\resource.syso versioninfo.json if errorlevel 1 exit /b 1 echo Building GUI -^> %OUT_GUI% go build -ldflags="-H windowsgui -s -w" -trimpath -o "%OUT_GUI%" ./cmd/vpnapp if errorlevel 1 exit /b 1 echo Building CLI -^> %OUT_CLI% go build -ldflags="-s -w" -trimpath -o "%OUT_CLI%" ./cmd/vpnclient if errorlevel 1 exit /b 1 mkdir "%DIST%" 2>nul copy /Y "%OUT_GUI%" "%DIST%\%OUT_GUI%" >nul if errorlevel 1 exit /b 1 copy /Y "%OUT_CLI%" "%DIST%\%OUT_CLI%" >nul if errorlevel 1 exit /b 1 REM Stable names for the update feed / installers (best-effort if file is locked) call :copy_alias "%OUT_GUI%" "%DIST%\Navis.exe" call :copy_alias "%OUT_CLI%" "%DIST%\vpnclient.exe" echo. echo Done: echo %OUT_GUI% echo %OUT_CLI% echo %DIST%\%OUT_GUI% echo %DIST%\%OUT_CLI% echo %DIST%\Navis.exe (update alias) echo assets\navis.ico endlocal exit /b 0 :bump_build where py >nul 2>&1 if not errorlevel 1 ( py -3 scripts\bump-build.py exit /b %ERRORLEVEL% ) where python >nul 2>&1 if not errorlevel 1 ( python scripts\bump-build.py exit /b %ERRORLEVEL% ) where python3 >nul 2>&1 if not errorlevel 1 ( python3 scripts\bump-build.py exit /b %ERRORLEVEL% ) REM PowerShell fallback when Python is not installed powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\bump-build.ps1" exit /b %ERRORLEVEL% :copy_alias if exist "%~2" del /F /Q "%~2" >nul 2>&1 copy /Y "%~1" "%~2" >nul 2>&1 if errorlevel 1 ( echo Warning: could not refresh %~2 ^(file in use^). Versioned build is still ready. exit /b 0 ) exit /b 0