1+ @ echo off
2+
3+ rem
4+ rem ASSEMBLE DISTRIBUTION PACKAGE
5+ rem
6+
7+ rem Set the target platform and the path to UPX
8+ set TARGET_PLATFORM = kitsu-file-parser
9+ set UPX_PATH = tools\upx-3.96-win64\upx.exe
10+
11+ rem Get the current date in the format YYYY-MM-DD
12+ for /f " tokens=1-3 delims=-" %%a in ('powershell -command " Get-Date -Format 'yyyy-MM-dd'" ') do set CURRENT_DATE = %%a -%%b -%%c
13+ set OUTPUT_ARCHIVE = dist\kitsu-file-parser-win-v%CURRENT_DATE% .zip
14+
15+ rem Run build-release.bat
16+ call build-release.bat
17+ if errorlevel 1 (
18+ echo " Build process failed."
19+ exit /b 1
20+ )
21+
22+ rem Create or clear the "dist" directory for the target platform
23+ if exist dist\%TARGET_PLATFORM% rmdir /s /q dist\%TARGET_PLATFORM%
24+ mkdir dist\%TARGET_PLATFORM%
25+
26+ rem Copy specified files and folders
27+ copy kitsu-file-parser.exe dist\%TARGET_PLATFORM%
28+ copy README.md dist\%TARGET_PLATFORM%
29+ copy LICENSE dist\%TARGET_PLATFORM%
30+ copy empty.conf.toml dist\%TARGET_PLATFORM% \conf.toml
31+ xcopy /E /I /Y assets dist\%TARGET_PLATFORM% \assets
32+
33+ rem Use UPX packer if available, otherwise download and use it
34+ if not exist %UPX_PATH% (
35+ echo " UPX not found. Downloading UPX..."
36+ mkdir tools
37+ powershell -command " & { Invoke-WebRequest -Uri 'https://github.com/upx/upx/releases/download/v3.96/upx-3.96-win64.zip' -OutFile 'tools\upx.zip' }"
38+ powershell -command " & { Expand-Archive -Path 'tools\upx.zip' -DestinationPath 'tools' }"
39+ del tools\upx.zip
40+ )
41+
42+ rem Pack the binary with UPX
43+ %UPX_PATH% --best dist\%TARGET_PLATFORM% \kitsu-file-parser.exe
44+
45+ rem Create a zip archive with version and current date
46+ powershell -command " & { Compress-Archive -Path 'dist\%TARGET_PLATFORM% ' -DestinationPath '%OUTPUT_ARCHIVE% ' -Force}"
0 commit comments