-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupload_pypi.bat
More file actions
executable file
·34 lines (26 loc) · 1.14 KB
/
upload_pypi.bat
File metadata and controls
executable file
·34 lines (26 loc) · 1.14 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
@echo off
REM GangDan - Build and upload to PyPI
setlocal
cd /d "%~dp0"
if not defined PYTHON set "PYTHON=python"
set "VERSION_FILE=gangdan\__init__.py"
echo === GangDan PyPI Upload ===
echo [1/5] Bumping patch version...
%PYTHON% -c "import re,sys;p='%VERSION_FILE%'.replace('\\','/');t=open(p).read();m=re.search(r'(__version__\s*=\s*\"(\d+\.\d+\.)(\d+)\")',t);old=m.group(2)+m.group(3);new=m.group(2)+str(int(m.group(3))+1);open(p,'w').write(t.replace(m.group(1),'__version__ = \"'+new+'\"'));print(f' {old} -> {new}')"
if %errorlevel% neq 0 (echo Version bump failed! & exit /b 1)
echo [2/5] Cleaning old builds...
if exist dist rmdir /s /q dist
if exist build rmdir /s /q build
for /d %%i in (*.egg-info) do rmdir /s /q "%%i"
echo [3/5] Installing build tools...
%PYTHON% -m pip install --upgrade build twine -q
echo [4/5] Building package...
%PYTHON% -m build
if %errorlevel% neq 0 (echo Build failed! & exit /b 1)
%PYTHON% -m twine check dist\*
if %errorlevel% neq 0 (echo Check failed! & exit /b 1)
echo [5/5] Uploading to PyPI...
%PYTHON% -m twine upload dist\*
if %errorlevel% neq 0 (echo Upload failed! & exit /b 1)
echo === Done! ===
endlocal