@echo off REM Upload wheel to Forgejo PyPI for Elytra PIM Client REM REM Prerequisites: REM 1. Create .pypirc file in project root REM 2. Copy from .pypirc.example and add your credentials REM REM Usage: REM upload_wheel_to_forgejo_pypi.bat [--build] REM Options: --build Force rebuild before upload setlocal enabledelayedexpansion set PYPIRC_SRC=%CD%\.pypirc set PYPIRC_DEST=%USERPROFILE%\.pypirc echo. echo ======================================================================== echo Elytra PIM Client - Upload to Forgejo PyPI echo ======================================================================== echo. REM Check for .pypirc if not exist ".pypirc" ( echo [!] .pypirc not found in project root! echo. echo Setup instructions: echo 1. cp .pypirc.example .pypirc echo 2. Edit .pypirc with your Forgejo credentials echo 3. Run this script again echo. pause exit /b 1 ) REM Copy .pypirc to user profile echo Configuring credentials... copy /Y "%PYPIRC_SRC%" "%PYPIRC_DEST%" > nul REM Activate virtual environment call .venv\Scripts\activate.bat REM Install twine if needed python -m pip list | find /I "twine" > nul if errorlevel 1 ( echo Installing twine... python -m pip install -q twine ) cd /d "%~dp0" REM Check for --build flag if "%~1"=="--build" ( echo Building wheel (forced)... rmdir /s /q dist > nul 2>&1 python build_wheel.py if errorlevel 1 ( del "%PYPIRC_DEST%" call .venv\Scripts\deactivate.bat exit /b 1 ) ) else ( REM Build wheel if not present if not exist dist\*.whl ( echo Building wheel... python build_wheel.py if errorlevel 1 ( del "%PYPIRC_DEST%" call .venv\Scripts\deactivate.bat exit /b 1 ) ) ) REM Upload to Forgejo PyPI echo. echo ======================================================================== echo Uploading to Forgejo PyPI... echo ======================================================================== echo. twine upload -r forgejo dist\*.whl set UPLOAD_RESULT=%errorlevel% REM Cleanup del "%PYPIRC_DEST%" call .venv\Scripts\deactivate.bat echo. echo ======================================================================== if %UPLOAD_RESULT% equ 0 ( echo Upload successful! ) else ( echo Upload failed ) echo ======================================================================== echo. endlocal pause exit /b %UPLOAD_RESULT% if errorlevel 1 ( echo Error: Build failed del "%PYPIRC_DEST%" call .venv\Scripts\deactivate.bat pause exit /b 1 ) ) ) REM Upload to Forgejo PyPI echo. echo ======================================================================== echo Uploading to Forgejo PyPI... echo ======================================================================== echo. twine upload -r forgejo dist\*.whl if errorlevel 1 ( echo. echo Error: Upload failed echo. echo Troubleshooting: echo - Verify .pypirc has correct credentials echo - Check Forgejo instance is reachable echo - Ensure access token is valid echo - Visit: https://your-forgejo-instance.com/user/settings/applications echo. del "%PYPIRC_DEST%" call .venv\Scripts\deactivate.bat pause exit /b 1 ) REM Cleanup echo. echo ======================================================================== echo Upload complete! echo ======================================================================== echo. call .venv\Scripts\deactivate.bat del "%PYPIRC_DEST%" echo [OK] Virtual environment deactivated echo [OK] Credentials removed echo. echo Your package is now available in your Forgejo PyPI repository. echo. pause endlocal