@echo off setlocal EnableExtensions EnableDelayedExpansion cd /d "%~dp0" set "PROPS=%CD%\gradle.properties" if not exist "%PROPS%" ( echo [ERROR] gradle.properties tidak ditemukan. pause exit /b 1 ) :refresh set "MOD_VERSION=" set "MINECRAFT_VERSION=" set "ARCHIVES_BASE_NAME=" for /f "usebackq tokens=1,* delims==" %%A in ("%PROPS%") do ( if "%%A"=="mod_version" set "MOD_VERSION=%%B" if "%%A"=="minecraft_version" set "MINECRAFT_VERSION=%%B" if "%%A"=="archives_base_name" set "ARCHIVES_BASE_NAME=%%B" ) if not defined MOD_VERSION set "MOD_VERSION=unknown" if not defined MINECRAFT_VERSION set "MINECRAFT_VERSION=26.2" if not defined ARCHIVES_BASE_NAME set "ARCHIVES_BASE_NAME=handcrafted" set "JAR_PATH=%CD%\build\libs\%ARCHIVES_BASE_NAME%-%MOD_VERSION%.jar" set "TAG=v%MOD_VERSION%" if exist "%JAR_PATH%" goto :menu4 echo. echo ============================================ echo Handcrafted Workflow echo Minecraft : %MINECRAFT_VERSION% echo Version : %MOD_VERSION% echo JAR : belum ditemukan echo ============================================ echo. echo Build untuk versi ini belum ada. Menjalankan compile... call :compile if errorlevel 1 goto :menu_nojar goto :menu4 :menu_nojar echo. echo Build gagal / JAR belum tersedia. echo [1] Push Git echo [2] Mod Testing echo [3] Exit choice /C 123 /N /M "Pilih: " if errorlevel 3 exit /b 0 if errorlevel 2 (call :test & goto :refresh) if errorlevel 1 (call :push & goto :refresh) :menu4 echo. echo ============================================ echo Handcrafted Workflow echo Minecraft : %MINECRAFT_VERSION% echo Version : %MOD_VERSION% echo JAR : ditemukan echo ============================================ echo [1] Push Git echo [2] Mod Testing echo [3] Make Release echo [4] Exit choice /C 1234 /N /M "Pilih: " if errorlevel 4 exit /b 0 if errorlevel 3 (call :release & goto :after_release) if errorlevel 2 (call :test & goto :after_test) if errorlevel 1 (call :push & goto :after_push) :after_push echo. echo [1] Mod Testing echo [2] Make Release echo [3] Exit choice /C 123 /N /M "Pilih: " if errorlevel 3 exit /b 0 if errorlevel 2 (call :release & goto :after_release) if errorlevel 1 (call :test & goto :after_test) :after_test echo. echo [1] Push Git echo [2] Make Release echo [3] Exit choice /C 123 /N /M "Pilih: " if errorlevel 3 exit /b 0 if errorlevel 2 (call :release & goto :after_release) if errorlevel 1 (call :push & goto :after_push) :after_release echo. echo [1] Push Git echo [2] Mod Testing echo [3] Exit choice /C 123 /N /M "Pilih: " if errorlevel 3 exit /b 0 if errorlevel 2 (call :test & goto :after_test) if errorlevel 1 (call :push & goto :after_push) :compile echo. echo [COMPILE] Building %ARCHIVES_BASE_NAME% %MOD_VERSION%... if exist "%CD%\compile.bat" ( call "%CD%\compile.bat" --build-only ) else if exist "%CD%\gradlew.bat" ( call "%CD%\gradlew.bat" clean build --console=plain ) else ( echo [ERROR] compile.bat maupun gradlew.bat tidak ditemukan. exit /b 1 ) if errorlevel 1 ( echo [ERROR] Compile gagal. exit /b 1 ) if not exist "%JAR_PATH%" ( echo [ERROR] Build selesai tetapi JAR tidak ditemukan: echo %JAR_PATH% exit /b 1 ) echo [OK] JAR: %JAR_PATH% exit /b 0 :push echo. echo [GIT] Push... where git.exe >nul 2>&1 || (echo [ERROR] Git tidak ditemukan.& exit /b 1) git rev-parse --is-inside-work-tree >nul 2>&1 || ( echo [ERROR] Folder belum menjadi Git repository. echo Jalankan: git init exit /b 1 ) git remote get-url origin >nul 2>&1 || (echo [ERROR] Remote origin belum dikonfigurasi.& exit /b 1) set "HAS_CHANGES=" for /f "delims=" %%G in ('git status --porcelain') do set "HAS_CHANGES=1" if defined HAS_CHANGES ( git status --short set "MSG=" set /p "MSG=Commit message [Handcrafted %MOD_VERSION%]: " if not defined MSG set "MSG=Handcrafted %MOD_VERSION%" git add -A || exit /b 1 git commit -m "!MSG!" || exit /b 1 ) else ( echo [INFO] Working tree bersih. ) set "BRANCH=" for /f "delims=" %%B in ('git branch --show-current') do set "BRANCH=%%B" if not defined BRANCH (echo [ERROR] Branch aktif tidak ditemukan.& exit /b 1) git push origin "!BRANCH!" if errorlevel 1 (echo [ERROR] Push gagal.& exit /b 1) echo [OK] Push selesai. exit /b 0 :test echo. echo [TEST] Menjalankan Minecraft test client... if exist "%CD%\gradlew.bat" ( call "%CD%\gradlew.bat" runClient --console=plain ) else ( echo [ERROR] gradlew.bat tidak ditemukan. exit /b 1 ) set "RC=%ERRORLEVEL%" if not "%RC%"=="0" echo [WARN] Test client selesai dengan exit code %RC%. exit /b 0 :release echo. if not exist "%JAR_PATH%" ( echo [ERROR] Release dibatalkan: JAR %MOD_VERSION% tidak ditemukan. exit /b 1 ) where git.exe >nul 2>&1 || (echo [ERROR] Git tidak ditemukan.& exit /b 1) git rev-parse --is-inside-work-tree >nul 2>&1 || (echo [ERROR] Bukan Git repository.& exit /b 1) git rev-parse "%TAG%" >nul 2>&1 if not errorlevel 1 ( echo [INFO] Tag %TAG% sudah ada. Tidak membuat ulang. exit /b 0 ) echo JAR : %JAR_PATH% echo Tag : %TAG% choice /C YN /N /M "Buat release tag %TAG%? [Y/N]: " if errorlevel 2 exit /b 0 git tag -a "%TAG%" -m "Handcrafted v%MOD_VERSION% for Fabric %MINECRAFT_VERSION%" if errorlevel 1 (echo [ERROR] Gagal membuat tag.& exit /b 1) git remote get-url origin >nul 2>&1 if not errorlevel 1 ( git push origin "%TAG%" if errorlevel 1 ( echo [WARN] Tag lokal dibuat, tetapi push tag gagal. exit /b 1 ) ) echo [OK] Release tag %TAG% selesai. echo [INFO] JAR release: %JAR_PATH% exit /b 0