Workflow file for this run
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: Upload Python Package to PyPI | |
on: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for proper versioning | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install uv | |
run: | | |
python -m pip install --upgrade pip | |
pip install uv | |
- name: Install build dependencies | |
run: | | |
uv venv .venv | |
source .venv/bin/activate | |
uv pip install build hatchling hatch-vcs | |
- name: Verify tag format | |
run: | | |
TAG_NAME=${{ github.ref_name }} | |
if [[ ! $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Error: Tag name '$TAG_NAME' does not match required format 'vX.Y.Z'" | |
exit 1 | |
fi | |
- name: Build package | |
run: | | |
source .venv/bin/activate | |
python -m build | |
- name: Store dist artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
retention-days: 7 | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/bbox-visualizer | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download dist artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
print-hash: true |