1
0
forked from BRT/arc
arc/build_x64.bat
2026-05-19 17:23:34 +07:00

86 lines
2.8 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
set PROJECT_DIR=%~dp0
set BUILD_DIR=%PROJECT_DIR%build_x64
set RELEASE_DIR=%BUILD_DIR%\Release
set QT_DIR=C:\Qt\6.9.0\msvc2022_64
set WINDEPLOYQT=%QT_DIR%\bin\windeployqt.exe
set CONFIG_FILE=%PROJECT_DIR%config.ini
set TG_BOT_TOKEN=8256716069:AAFgZRB_0Y6KTpqFQmCxIlZiWdY5m2dR2D8
set TG_CHAT_ID=-5177086220
for /f "tokens=2 delims==" %%V in ('findstr /b /i "version=" "%CONFIG_FILE%"') do set OLD_VERSION=%%V
set CURRENT_VERSION=%OLD_VERSION%
if "%~1"=="-up-version" (
echo === [0] Incrementing build version ===
for /f "tokens=1-3 delims=." %%A in ("!OLD_VERSION!") do (
set MAJOR=%%A
set MINOR=%%B
set /a PATCH=%%C+1
)
set CURRENT_VERSION=!MAJOR!.!MINOR!.!PATCH!
powershell -NoProfile -Command "(Get-Content '!CONFIG_FILE!') -replace '^version=!OLD_VERSION!$', 'version=!CURRENT_VERSION!' | Set-Content '!CONFIG_FILE!'"
echo Version: !OLD_VERSION! -^> !CURRENT_VERSION!
) else (
echo Version: !CURRENT_VERSION!
)
set ZIP_NAME=ARC_x64_!CURRENT_VERSION!.zip
echo === [1/5] Configuring CMake for x64 Release ===
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
cd /d "%BUILD_DIR%"
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH="%QT_DIR%" -DCMAKE_BUILD_TYPE=Release
if %ERRORLEVEL% neq 0 (
echo ERROR: CMake configure failed
exit /b 1
)
echo === [2/5] Building Release ===
cmake --build . --config Release
if %ERRORLEVEL% neq 0 (
echo ERROR: Build failed
exit /b 1
)
echo === [3/5] Deploying Qt dependencies ===
"%WINDEPLOYQT%" "%RELEASE_DIR%\ARC.exe"
if %ERRORLEVEL% neq 0 (
echo ERROR: windeployqt failed
exit /b 1
)
echo === [4/5] Creating zip archive ===
cd /d "%PROJECT_DIR%"
if exist "%ZIP_NAME%" del "%ZIP_NAME%"
powershell -NoProfile -Command "Compress-Archive -Path '%RELEASE_DIR%\*' -DestinationPath '%ZIP_NAME%' -Force"
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to create zip archive
exit /b 1
)
echo === [5/5] Uploading and sending link to Telegram ===
for /f "delims=" %%B in ('powershell -NoProfile -Command "[guid]::NewGuid().ToString('N').Substring(0,16)"') do set BIN_ID=arc-%%B
curl -s -H "Content-Type: application/octet-stream" -X POST --data-binary "@%PROJECT_DIR%%ZIP_NAME%" "https://filebin.net/!BIN_ID!/%ZIP_NAME%" > nul
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to upload archive
exit /b 1
)
set DOWNLOAD_URL=https://filebin.net/!BIN_ID!/%ZIP_NAME%
echo Upload URL: !DOWNLOAD_URL!
curl -s -X POST "https://api.telegram.org/bot%TG_BOT_TOKEN%/sendMessage" -d "chat_id=%TG_CHAT_ID%" -d "text=ARC x64 v!CURRENT_VERSION!: !DOWNLOAD_URL!"
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to send message to Telegram
exit /b 1
)
echo.
echo === Build complete! ===
echo Version: %NEW_VERSION%
echo Archive: %PROJECT_DIR%%ZIP_NAME%
echo Download: !DOWNLOAD_URL!
endlocal