Improve build script reliability.

This commit is contained in:
John Preston
2026-07-15 13:09:41 +04:00
parent a6209e3993
commit fd82189744
+38 -47
View File
@@ -186,12 +186,10 @@ if %AlphaVersion% neq 0 (
cd "%HomePath%"
call configure.bat -DDESKTOP_APP_ENABLE_LTO=ON
if %errorlevel% neq 0 goto error
call configure.bat -DDESKTOP_APP_ENABLE_LTO=ON || goto error
cd "%SolutionPath%"
call cmake --build . --config Release --target Telegram
if %errorlevel% neq 0 goto error
call cmake --build . --config Release --target Telegram || goto error
echo.
echo Version %AppVersionStrFull% build successfull. Preparing..
@@ -210,33 +208,21 @@ set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5"
cd "%ReleasePath%"
:sign1
call "%SignPath%" "%BinaryName%.exe"
if %errorlevel% neq 0 (
timeout /t 3
goto sign1
)
call :sign "%BinaryName%.exe"
if %BuildUWP% equ 0 (
:sign2
call "%SignPath%" "Updater.exe"
if %errorlevel% neq 0 (
timeout /t 3
goto sign2
)
call :sign "Updater.exe"
if %AlphaVersion% equ 0 (
iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppVersionFull=%AppVersionStrFull% "/dReleasePath=%ReleasePath%" "/dMyBuildTarget=%BuildTarget%" "%FullScriptPath%setup.iss"
if %errorlevel% neq 0 goto error
iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppVersionFull=%AppVersionStrFull% "/dReleasePath=%ReleasePath%" "/dMyBuildTarget=%BuildTarget%" "%FullScriptPath%setup.iss" || goto error
if not exist "%SetupFile%" goto error
)
if %BuildARM% neq 0 (
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe -target %BuildTarget% %AlphaBetaParam%
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe -target %BuildTarget% %AlphaBetaParam% || goto error
) else (
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe -path "modules\%Platform%\d3d\d3dcompiler_47.dll" -target %BuildTarget% %AlphaBetaParam%
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe -path "modules\%Platform%\d3d\d3dcompiler_47.dll" -target %BuildTarget% %AlphaBetaParam% || goto error
)
if %errorlevel% neq 0 goto error
if %AlphaVersion% neq 0 (
if not exist "%ReleasePath%\%AlphaKeyFile%" (
@@ -246,19 +232,13 @@ if %BuildUWP% equ 0 (
FOR /F "tokens=1* delims= " %%i in (%ReleasePath%\%AlphaKeyFile%) do set "AlphaSignature=%%i"
)
if %errorlevel% neq 0 goto error
if %AlphaVersion% neq 0 (
set "UpdateFile=!UpdateFile!_!AlphaSignature!"
set "PortableFile=talpha!AlphaVersion!_!AlphaSignature!.zip"
)
) else (
:sign2
call "%SignPath%" "StartupTask.exe"
if %errorlevel% neq 0 (
timeout /t 3
goto sign2
)
call :sign "StartupTask.exe"
)
for /f ^"usebackq^ eol^=^
@@ -285,8 +265,7 @@ if %BuildUWP% neq 0 (
xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX\" /E
set "ResourcePath=%ReleasePath%\AppX\AppxManifest.xml"
call :repl "Argument= (ProcessorArchitecture=)"ARCHITECTURE"/ $1"%Platform%"" "Filename=!ResourcePath!" || goto error
makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX\AppxManifest.xml /of %ReleasePath%\AppX\resources.pri
if %errorlevel% neq 0 goto error
makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX\AppxManifest.xml /of %ReleasePath%\AppX\resources.pri || goto error
xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX\"
xcopy "%ReleasePath%\StartupTask.exe" "%ReleasePath%\AppX\"
@@ -294,8 +273,7 @@ if %BuildUWP% neq 0 (
xcopy "%ReleasePath%\modules\%Platform%\d3d\d3dcompiler_47.dll" "%ReleasePath%\AppX\modules\%Platform%\d3d\"
)
MakeAppx.exe pack /d "%ReleasePath%\AppX" /l /p ..\out\Release\%BinaryName%.%Platform%.appx
if %errorlevel% neq 0 goto error
MakeAppx.exe pack /d "%ReleasePath%\AppX" /l /p ..\out\Release\%BinaryName%.%Platform%.appx || goto error
if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
@@ -313,29 +291,25 @@ if %BuildUWP% neq 0 (
) else (
if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
mkdir "%DeployPath%\%BinaryName%\modules\%Platform%\d3d"
if %errorlevel% neq 0 goto error
mkdir "%DeployPath%\%BinaryName%\modules\%Platform%\d3d" || goto error
move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\%BinaryName%\"
xcopy "%ReleasePath%\modules\%Platform%\d3d\d3dcompiler_47.dll" "%DeployPath%\%BinaryName%\modules\%Platform%\d3d\"
move "%ReleasePath%\Updater.exe" "%DeployPath%\"
move "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\"
move "%ReleasePath%\Updater.pdb" "%DeployPath%\"
move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\%BinaryName%\" || goto error
xcopy "%ReleasePath%\modules\%Platform%\d3d\d3dcompiler_47.dll" "%DeployPath%\%BinaryName%\modules\%Platform%\d3d\" || goto error
move "%ReleasePath%\Updater.exe" "%DeployPath%\" || goto error
move "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\" || goto error
move "%ReleasePath%\Updater.pdb" "%DeployPath%\" || goto error
if %AlphaVersion% equ 0 (
move "%ReleasePath%\%SetupFile%" "%DeployPath%\"
move "%ReleasePath%\%SetupFile%" "%DeployPath%\" || goto error
) else (
move "%ReleasePath%\%AlphaKeyFile%" "%DeployPath%\"
move "%ReleasePath%\%AlphaKeyFile%" "%DeployPath%\" || goto error
)
move "%ReleasePath%\%UpdateFile%" "%DeployPath%\"
if %errorlevel% neq 0 goto error
move "%ReleasePath%\%UpdateFile%" "%DeployPath%\" || goto error
cd "%DeployPath%"
7z a -mx9 %PortableFile% %BinaryName%\
if %errorlevel% neq 0 goto error
call :packportable
move "%DeployPath%\%BinaryName%\%BinaryName%.exe" "%DeployPath%\"
move "%DeployPath%\%BinaryName%\%BinaryName%.exe" "%DeployPath%\" || goto error
rmdir "%DeployPath%\%BinaryName%"
if %errorlevel% neq 0 goto error
)
if %Build64% neq 0 (
@@ -409,3 +383,20 @@ exit /b
del %TempFilename%
exit /b !ErrorCode!
)
:sign
call "%SignPath%" %1 && exit /b 0
echo Signing %1 failed, retrying in 3 seconds..
timeout /t 3
goto sign
:packportable
7z a -mx9 %PortableFile% %BinaryName%\ || goto packportableretry
7z t %PortableFile% || goto packportableretry
exit /b 0
:packportableretry
echo Packing %PortableFile% failed, retrying in 3 seconds..
if exist "%PortableFile%" del "%PortableFile%"
timeout /t 3
goto packportable