Publish to PyPI #12
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: Publish to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| # 1.8.1 shipped with VERSION and __init__.py still reading 1.8.0. The | |
| # guard test caught it, but only on the push-triggered CI run, after the | |
| # release had been cut and published. PyPI does not allow overwriting a | |
| # published file, so that artifact is permanently wrong. | |
| # | |
| # These steps run ci.yml's checks on the 3.11 leg only — black, ruff and | |
| # the unit suite. They are NOT full CI: the 3.9 and 3.12 legs still run | |
| # only on push, so version-incompatible syntax is caught there, not here. | |
| # Extras match the 3.11 CI job so the gate covers the Solana paths; with | |
| # the plain extra those tests importorskip and pass silently. | |
| - name: Install package and test deps | |
| run: pip install -e ".[dev,solana]" build | |
| # A release tag that disagrees with the package version means the wrong | |
| # tree is being published. PyPI would reject a duplicate version, but | |
| # only after the release is cut; fail here instead. | |
| - name: Verify the release tag matches VERSION | |
| run: | | |
| tag="${{ github.event.release.tag_name }}" | |
| declared="v$(tr -d '[:space:]' < VERSION)" | |
| if [ "$tag" != "$declared" ]; then | |
| echo "Release tag $tag does not match VERSION ($declared)." >&2 | |
| exit 1 | |
| fi | |
| echo "Release tag $tag matches VERSION." | |
| - name: Check formatting | |
| run: black --check blockrun_llm/ tests/ | |
| - name: Lint | |
| run: ruff check blockrun_llm/ tests/ | |
| - name: Verify the release is publishable | |
| run: pytest tests/unit -q | |
| - name: Build package | |
| run: python -m build | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |