|
1 | | -name: Publish |
| 1 | +name: PyPI Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + |
2 | 8 | permissions: |
3 | | - checks: write |
4 | | - contents: write |
5 | | - pull-requests: write |
6 | | - statuses: write |
7 | | -"on": |
8 | | - push: |
9 | | - branches: |
10 | | - - main |
11 | | - paths: |
12 | | - - RELEASES.md |
13 | | - - '*/RELEASES.md' |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: release |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +env: |
| 16 | + PYTHON_VERSION: "3.13" |
| 17 | + |
14 | 18 | jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v5 |
| 25 | + |
| 26 | + - uses: astral-sh/setup-uv@v7 |
| 27 | + with: |
| 28 | + python-version: ${{ env.PYTHON_VERSION }} |
| 29 | + |
| 30 | + - name: Set up Python |
| 31 | + uses: actions/setup-python@v6 |
| 32 | + with: |
| 33 | + python-version: ${{ env.PYTHON_VERSION }} |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + env: |
| 37 | + UV_LOCKED: "1" |
| 38 | + UV_PYTHON: ${{ env.PYTHON_VERSION }} |
| 39 | + run: make install |
| 40 | + |
| 41 | + - name: Validate version matches release tag |
| 42 | + env: |
| 43 | + TAG: ${{ github.event.release.tag_name }} |
| 44 | + run: | |
| 45 | + PKG_VERSION=$(PYTHONPATH=src uv run python - <<'PYEOF' |
| 46 | + from unstructured_client._version import __version__ |
| 47 | + print(__version__) |
| 48 | + PYEOF |
| 49 | + ) |
| 50 | + if [[ "$TAG" != "$PKG_VERSION" && "$TAG" != "v$PKG_VERSION" ]]; then |
| 51 | + echo "Tag '$TAG' does not match package version '$PKG_VERSION'" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Build artifacts |
| 56 | + run: uv build --out-dir dist --clear |
| 57 | + |
| 58 | + - name: Upload dist artifacts |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: python-package-distributions |
| 62 | + path: dist/ |
| 63 | + |
15 | 64 | publish: |
16 | | - uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-publish.yaml@v15 |
17 | | - secrets: |
18 | | - github_access_token: ${{ secrets.GITHUB_TOKEN }} |
19 | | - pypi_token: ${{ secrets.PYPI_TOKEN }} |
20 | | - speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }} |
| 65 | + needs: build |
| 66 | + runs-on: ubuntu-latest |
| 67 | + permissions: |
| 68 | + contents: read |
| 69 | + id-token: write |
| 70 | + steps: |
| 71 | + - name: Download dist artifacts |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + name: python-package-distributions |
| 75 | + path: dist/ |
| 76 | + |
| 77 | + - name: Publish package |
| 78 | + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1 |
0 commit comments