|
| 1 | +name: Release |
| 2 | + |
| 3 | +# On a published GitHub Release: gate on the full test suite (ci.yml), build the sdist + |
| 4 | +# wheel, attach them to the Release, and (opt-in) publish to PyPI. |
| 5 | +# |
| 6 | +# vgi-python workers ship to PyPI, NOT as a compiled binary. PyPI upload uses Trusted |
| 7 | +# Publishing (OIDC — no API tokens) and is GATED behind the repo variable PYPI_PUBLISH: |
| 8 | +# it stays skipped until a maintainer sets `PYPI_PUBLISH=true` AND configures a Trusted |
| 9 | +# Publisher on PyPI for the `vgi-news` project pointing at: |
| 10 | +# owner: Query-farm · repo: vgi-news · workflow: release.yml · environment: pypi |
| 11 | +# Until then the Release still ships installable sdist+wheel assets, CI-gated and green. |
| 12 | + |
| 13 | +on: |
| 14 | + release: |
| 15 | + types: [published] |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + ci: |
| 23 | + uses: ./.github/workflows/ci.yml |
| 24 | + |
| 25 | + build: |
| 26 | + name: Build + attach distributions |
| 27 | + needs: [ci] |
| 28 | + runs-on: ubuntu-latest |
| 29 | + permissions: |
| 30 | + contents: write # attach assets to the Release |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - name: Install uv |
| 34 | + uses: astral-sh/setup-uv@v5 |
| 35 | + - name: Check version matches tag |
| 36 | + if: github.event_name == 'release' |
| 37 | + run: ci/check-version.sh "${{ github.event.release.tag_name }}" |
| 38 | + - name: Build sdist + wheel |
| 39 | + run: uv build --sdist --wheel --out-dir dist . |
| 40 | + - name: Validate metadata |
| 41 | + run: uvx twine check dist/* |
| 42 | + - name: Upload build artifacts |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: dist |
| 46 | + path: dist/ |
| 47 | + - name: Attach distributions to the Release |
| 48 | + if: github.event_name == 'release' |
| 49 | + env: |
| 50 | + GH_TOKEN: ${{ github.token }} |
| 51 | + run: gh release upload "${{ github.event.release.tag_name }}" dist/* --clobber |
| 52 | + |
| 53 | + publish: |
| 54 | + name: Publish to PyPI (opt-in) |
| 55 | + needs: [build] |
| 56 | + # Skipped until the maintainer enables PyPI Trusted Publishing (see header). A skipped |
| 57 | + # job does not fail the workflow, so releases stay green before PyPI is configured. |
| 58 | + if: ${{ vars.PYPI_PUBLISH == 'true' }} |
| 59 | + runs-on: ubuntu-latest |
| 60 | + environment: pypi |
| 61 | + permissions: |
| 62 | + id-token: write # required for Trusted Publishing |
| 63 | + steps: |
| 64 | + - name: Download artifacts |
| 65 | + uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + name: dist |
| 68 | + path: dist/ |
| 69 | + - name: Publish |
| 70 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments