Repository navigation
Expand file tree
/
Copy pathbuild.bat
More file actions
57 lines (49 loc) · 2 KB
/
Copy pathbuild.bat
File metadata and controls
57 lines (49 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@echo off
setlocal
echo === PDF eSign ^| PyInstaller build ===
set "PYTHON_EXE=%~dp0.venv\Scripts\python.exe"
if not exist "%PYTHON_EXE%" set "PYTHON_EXE=python"
"%PYTHON_EXE%" -c "import PyInstaller" >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo.
echo PyInstaller is not installed for "%PYTHON_EXE%".
echo Install build dependencies with:
echo "%PYTHON_EXE%" -m pip install -r requirements-dev.txt
exit /b 1
)
echo Cleaning previous build artifacts...
if exist build rmdir /s /q build
if exist dist rmdir /s /q dist
echo Building executable...
"%PYTHON_EXE%" -m PyInstaller pdf_esign.spec --noconfirm
if %ERRORLEVEL% neq 0 (
echo.
echo BUILD FAILED -- check output above
exit /b 1
)
set "RELEASE_EXE=dist\PDF-eSign\PDF-eSign.exe"
if defined PDF_ESIGN_CODESIGN_PFX (
if not defined PDF_ESIGN_CODESIGN_PASSWORD (
echo PDF_ESIGN_CODESIGN_PASSWORD is required when code signing is enabled.
exit /b 1
)
if not defined PDF_ESIGN_SIGNTOOL set "PDF_ESIGN_SIGNTOOL=signtool.exe"
echo Applying Authenticode signature...
if defined PDF_ESIGN_TIMESTAMP_URL (
"%PDF_ESIGN_SIGNTOOL%" sign /fd SHA256 /td SHA256 /tr "%PDF_ESIGN_TIMESTAMP_URL%" /f "%PDF_ESIGN_CODESIGN_PFX%" /p "%PDF_ESIGN_CODESIGN_PASSWORD%" "%RELEASE_EXE%"
) else (
"%PDF_ESIGN_SIGNTOOL%" sign /fd SHA256 /f "%PDF_ESIGN_CODESIGN_PFX%" /p "%PDF_ESIGN_CODESIGN_PASSWORD%" "%RELEASE_EXE%"
)
if errorlevel 1 exit /b 1
"%PDF_ESIGN_SIGNTOOL%" verify /pa /v "%RELEASE_EXE%"
if errorlevel 1 exit /b 1
) else (
echo Local build is unsigned. Release CI requires an Authenticode credential.
)
powershell -NoProfile -Command "(Get-FileHash -Algorithm SHA256 -LiteralPath '%RELEASE_EXE%').Hash.ToLower() + ' PDF-eSign.exe' | Set-Content -Encoding ascii -LiteralPath 'dist\PDF-eSign\SHA256SUMS.txt'"
if %ERRORLEVEL% neq 0 exit /b 1
echo.
echo === BUILD COMPLETE ===
echo Output: dist\PDF-eSign\
for %%F in (%RELEASE_EXE%) do echo EXE Size: %%~zF bytes
echo Checksum: dist\PDF-eSign\SHA256SUMS.txt