72 lines
2.7 KiB
YAML
72 lines
2.7 KiB
YAML
# This workflow builds the PyO3-based native library across several platforms (using different runners),
|
|
# and then publishes the wheels to PyPi as a single release.
|
|
|
|
# SECURITY NOTE: We should disable all caches when building a public release to mitigate cache poisoning attacks.
|
|
|
|
name: Publish PyO3 client to PyPI
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types: [released]
|
|
|
|
permissions: {}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build-wheels:
|
|
if: github.repository == 'tensorzero/tensorzero'
|
|
uses: ./.github/workflows/python-client-build.yml
|
|
with:
|
|
use_cache: false
|
|
permissions:
|
|
contents: read # Required for checkout or repository metadata reads.
|
|
id-token: write # Required for OIDC-backed build or publish tooling.
|
|
|
|
release:
|
|
if: github.repository == 'tensorzero/tensorzero'
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
needs: [build-wheels]
|
|
environment: pypi-publish
|
|
permissions:
|
|
id-token: write # Required for OIDC-backed build or publish tooling.
|
|
contents: write # Required to push generated branch changes.
|
|
attestations: write # Required to publish artifact attestations.
|
|
# Download all of the wheel artifacts published by the other jobs,
|
|
# and publish them to PyPi as a new release, using the `upload-python-client.sh` script.
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
|
|
- name: Generate artifact attestation
|
|
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
|
|
with:
|
|
subject-path: "wheels-*/*"
|
|
|
|
- name: Publish to real PyPI (only on GitHub release)
|
|
if: ${{ github.event_name == 'release' }}
|
|
run: |
|
|
./ci/upload-python-client.sh pypi
|
|
|
|
- name: Publish to TestPyPI
|
|
run: |
|
|
./ci/upload-python-client.sh testpypi
|
|
# TestPyPI is frequently down for maintenance, so don't fail the workflow
|
|
# when making actual releases. We still fail on the job when running the
|
|
# workflow manually, as that's the only reason we'd want to run it.
|
|
continue-on-error: ${{ github.event_name == 'release' }}
|
|
|
|
upgrade-tensorzero-deps:
|
|
if: github.repository == 'tensorzero/tensorzero' && github.event_name == 'release'
|
|
needs: [release]
|
|
uses: ./.github/workflows/upgrade-tensorzero-deps.yml
|
|
permissions:
|
|
contents: write # Required to push generated branch changes.
|
|
pull-requests: write # Required to update PR comments, labels, or branches.
|