Repository navigation
Expand file tree
/
Copy pathbuild_windows.bat
More file actions
98 lines (87 loc) · 4.24 KB
/
Copy pathbuild_windows.bat
File metadata and controls
98 lines (87 loc) · 4.24 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@echo off
setlocal
cd /d "%~dp0"
for /f "usebackq delims=" %%V in (`powershell -NoProfile -Command "(Select-String -Path 'Downloader\src\core\config.py' -Pattern 'VERSION = .([0-9.]+).').Matches[0].Groups[1].Value"`) do set "APP_VERSION=%%V"
if not defined APP_VERSION (
echo Error: could not read VERSION from Downloader\src\core\config.py
exit /b 1
)
echo [1/6] Verifying pre-build requirements for v%APP_VERSION%...
if not exist ffmpeg.exe (
echo Error: ffmpeg.exe not found at repository root.
exit /b 1
)
powershell -NoProfile -Command "$expected = '228D7A8556258DE907FDB55F36850078EBC7680B84EC30D84EA02E99BEC1D1EB'; $actual = (Get-FileHash -Path 'ffmpeg.exe' -Algorithm SHA256).Hash; if ($actual -ne $expected) { Write-Error ('ffmpeg.exe SHA-256 mismatch! Expected: ' + $expected + ' but got: ' + $actual); exit 1 }" || exit /b 1
set "PYTHON_EXE="
set "PYTHON_ARGS="
where py >nul 2>nul
if not errorlevel 1 (
py -3 --version >nul 2>nul
if not errorlevel 1 (
set "PYTHON_EXE=py"
set "PYTHON_ARGS=-3"
)
)
if not defined PYTHON_EXE (
where python >nul 2>nul
if not errorlevel 1 (
python --version >nul 2>nul
if not errorlevel 1 set "PYTHON_EXE=python"
)
)
if not defined PYTHON_EXE (
for /f "delims=" %%P in ('dir /b /s "%LocalAppData%\Programs\Python\Python*\python.exe" 2^>nul') do if not defined PYTHON_EXE (
"%%P" --version >nul 2>nul
if not errorlevel 1 set "PYTHON_EXE=%%P"
)
)
if not defined PYTHON_EXE (
echo Error: Python 3 was not found.
exit /b 1
)
echo [2/6] Preparing virtual environment...
if not exist .build-venv (
"%PYTHON_EXE%" %PYTHON_ARGS% -m venv .build-venv || exit /b 1
)
call ".build-venv\Scripts\activate.bat"
python -m pip install -r requirements-build.txt || exit /b 1
echo [3/6] Running pre-build quality gates...
set "PYTHONPATH=Downloader"
python -m compileall -q Downloader\src Downloader\main.py || exit /b 1
python Downloader\tools\check_rules.py || exit /b 1
python Downloader\tools\check_ai_slop.py || exit /b 1
python -m pytest -q Downloader\tests || exit /b 1
echo [4/6] Building standalone executable with PyInstaller...
".build-venv\Scripts\pyinstaller.exe" --noconfirm --clean MediaDownloaderPRO.spec || exit /b 1
echo [5/6] Creating release archives and SHA-256 checksums...
powershell -NoProfile -Command "$zip = 'dist\MediaDownloaderPRO-v%APP_VERSION%-Windows-x64.zip'; $sha = 'dist\MediaDownloaderPRO-v%APP_VERSION%-Windows-x64.zip.sha256'; Compress-Archive -Path 'dist\MediaDownloaderPRO\*' -DestinationPath $zip -Force; (Get-FileHash -Path $zip -Algorithm SHA256).Hash.ToLower() | Out-File -FilePath $sha -Encoding ascii" || exit /b 1
set "ISCC_EXE="
where iscc >nul 2>nul
if not errorlevel 1 set "ISCC_EXE=iscc"
if not defined ISCC_EXE (
if exist "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" set "ISCC_EXE=C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
)
if not defined ISCC_EXE (
if exist "C:\Program Files\Inno Setup 6\ISCC.exe" set "ISCC_EXE=C:\Program Files\Inno Setup 6\ISCC.exe"
)
if not defined ISCC_EXE (
if exist "%LocalAppData%\Programs\Inno Setup 6\ISCC.exe" set "ISCC_EXE=%LocalAppData%\Programs\Inno Setup 6\ISCC.exe"
)
if defined ISCC_EXE (
echo Compiling Inno Setup installer...
"%ISCC_EXE%" "/DMyAppVersion=%APP_VERSION%" installer.iss || exit /b 1
powershell -NoProfile -Command "$inst = 'dist\MediaDownloaderPRO-v%APP_VERSION%-Setup.exe'; $sha = 'dist\MediaDownloaderPRO-v%APP_VERSION%-Setup.exe.sha256'; (Get-FileHash -Path $inst -Algorithm SHA256).Hash.ToLower() | Out-File -FilePath $sha -Encoding ascii" || exit /b 1
)
echo [6/6] Executing smoke test on standalone binary...
"dist\MediaDownloaderPRO\MediaDownloaderPRO.exe" --test-startup || exit /b 1
echo ========================================================
echo Release build and automated verification successful!
echo Binary: dist\MediaDownloaderPRO\MediaDownloaderPRO.exe
echo Package: dist\MediaDownloaderPRO-v%APP_VERSION%-Windows-x64.zip
echo Checksum: dist\MediaDownloaderPRO-v%APP_VERSION%-Windows-x64.zip.sha256
if defined ISCC_EXE (
echo Installer: dist\MediaDownloaderPRO-v%APP_VERSION%-Setup.exe
echo Checksum: dist\MediaDownloaderPRO-v%APP_VERSION%-Setup.exe.sha256
)
echo ========================================================
endlocal