@echo off
rem Clean old build
echo Clean old build...
if exist dist (
    rmdir /s /q dist
)
mkdir dist 2>nul

rem Auto bump version
echo Auto bump version...
for /f "delims=" %%v in ('python bump_version.py') do set "NEW_VERSION=%%v"
echo Version updated: %NEW_VERSION%

rem Build package
echo Build new version...
python -m build

rem Git commit
set "COMMIT_MSG=idl update - %NEW_VERSION%"
if not "%~1"=="" (
    set "COMMIT_MSG=%NEW_VERSION% - %~1"
)
git add .
git commit -m "%COMMIT_MSG%"
git push

rem Upload to PyPI
echo Uploading to PyPI...
twine upload dist/*

echo Publish done!
echo Commit message: %COMMIT_MSG%