PyPI Upload #41
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: PyPI Upload | |
| on: | |
| workflow_run: | |
| workflows: ["Python CI"] | |
| types: | |
| - completed | |
| jobs: | |
| publish: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| # Only publish on successful CI runs for tags starting with 'v' (e.g., v1.2.3) | |
| if: | | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| startsWith(github.event.workflow_run.head_branch, 'v') | |
| permissions: | |
| contents: read | |
| id-token: write | |
| actions: read | |
| env: | |
| UV_LOCKED: true | |
| UV_COMPILE_BYTECODE: true | |
| UV_NO_EDITABLE: true | |
| UV_NO_PROGRESS: true | |
| UV_NO_SYNC: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install uv and set the python version | |
| id: setup-uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| # https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions | |
| # It is considered best practice to pin to a specific uv version | |
| version: "0.9.26" | |
| # https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching | |
| enable-cache: true | |
| cache-dependency-glob: uv.lock | |
| - name: Download Python package artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: python-package | |
| path: dist/ | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install package from wheel | |
| run: uv pip install dist/*.whl | |
| - name: Run functional tests | |
| run: uv run pytest -m functional | |
| - name: Publish package to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |