Release to TestPyPI #68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release to TestPyPI | |
| on: | |
| push: | |
| tags: | |
| - "v*" # Triggers when you push a tag like v0.1.4, v1.0.0, etc. | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| build-and-publish: | |
| name: Build and Publish to TestPyPI | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Check out the code with full git history (required for hatch-vcs to see tags) | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # CRITICAL: Fetch all history including tags | |
| # 2. Set up Python | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| # 3. Install dev dependencies including hatch | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| # 4. Build the package | |
| # hatch-vcs will automatically detect the git tag and use it as the version | |
| - name: Build package | |
| run: hatch build | |
| # 5. Publish to TestPyPI | |
| - name: Publish to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| repository-url: https://test.pypi.org/legacy/ | |
| verbose: true # Shows detailed output for debugging | |
| skip-existing: true # Skip if version already exists |