Skip to content

Commit

Permalink
add better dist assembly script
Browse files Browse the repository at this point in the history
  • Loading branch information
keshon committed Jan 14, 2025
1 parent 6ee64fa commit 4985f11
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
# App
conf.toml
/release
/tmp
/tmp
/tools

*.zip
/dist
46 changes: 46 additions & 0 deletions build-dist-assemble.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@echo off

rem
rem ASSEMBLE DISTRIBUTION PACKAGE
rem

rem Set the target platform and the path to UPX
set TARGET_PLATFORM=kitsu-file-parser
set UPX_PATH=tools\upx-3.96-win64\upx.exe

rem Get the current date in the format YYYY-MM-DD
for /f "tokens=1-3 delims=-" %%a in ('powershell -command "Get-Date -Format 'yyyy-MM-dd'"') do set CURRENT_DATE=%%a-%%b-%%c
set OUTPUT_ARCHIVE=dist\kitsu-file-parser-win-v%CURRENT_DATE%.zip

rem Run build-release.bat
call build-release.bat
if errorlevel 1 (
echo "Build process failed."
exit /b 1
)

rem Create or clear the "dist" directory for the target platform
if exist dist\%TARGET_PLATFORM% rmdir /s /q dist\%TARGET_PLATFORM%
mkdir dist\%TARGET_PLATFORM%

rem Copy specified files and folders
copy kitsu-file-parser.exe dist\%TARGET_PLATFORM%
copy README.md dist\%TARGET_PLATFORM%
copy LICENSE dist\%TARGET_PLATFORM%
copy empty.conf.toml dist\%TARGET_PLATFORM%\conf.toml
xcopy /E /I /Y assets dist\%TARGET_PLATFORM%\assets

rem Use UPX packer if available, otherwise download and use it
if not exist %UPX_PATH% (
echo "UPX not found. Downloading UPX..."
mkdir tools
powershell -command "& { Invoke-WebRequest -Uri 'https://github.com/upx/upx/releases/download/v3.96/upx-3.96-win64.zip' -OutFile 'tools\upx.zip' }"
powershell -command "& { Expand-Archive -Path 'tools\upx.zip' -DestinationPath 'tools' }"
del tools\upx.zip
)

rem Pack the binary with UPX
%UPX_PATH% --best dist\%TARGET_PLATFORM%\kitsu-file-parser.exe

rem Create a zip archive with version and current date
powershell -command "& { Compress-Archive -Path 'dist\%TARGET_PLATFORM%' -DestinationPath '%OUTPUT_ARCHIVE%' -Force}"

0 comments on commit 4985f11

Please sign in to comment.