Publish Python stack #11
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 Python stack | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| release_ref: | |
| description: Existing release tag to rebuild and publish | |
| required: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: Build and verify distributions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Oída | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.release_ref || github.ref_name }} | |
| fetch-depth: 0 | |
| path: oida | |
| - name: Checkout AKOÚŌ contract | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: sonicfieldlabs/akouo | |
| ref: v0.9.2 | |
| path: akouo | |
| - name: Checkout Earworm | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: sonicfieldlabs/earworm | |
| ref: v0.7.0 | |
| path: earworm | |
| - name: Checkout Akousmata | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: sonicfieldlabs/akousmata | |
| ref: v0.7.0 | |
| path: akousmata | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2 | |
| with: | |
| version: "0.12.3" | |
| python-version: "3.12" | |
| - name: Verify release tag and project version | |
| working-directory: oida | |
| env: | |
| RELEASE_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.release_ref || github.ref_name }} | |
| run: | | |
| case "$RELEASE_REF" in | |
| v*) ;; | |
| *) echo "release_ref must name a v-prefixed release tag" >&2; exit 1 ;; | |
| esac | |
| test "$(git describe --tags --exact-match HEAD)" = "$RELEASE_REF" | |
| release_version="${RELEASE_REF#v}" | |
| project_version="$(uv version --short)" | |
| test "$release_version" = "$project_version" | |
| - name: Build all canonical distributions | |
| run: | | |
| mkdir -p release/akouo release/akousma release/akousmata release/oida | |
| uv build --out-dir "$GITHUB_WORKSPACE/release/akouo" akouo | |
| uv build --out-dir "$GITHUB_WORKSPACE/release/akousma" earworm/packages/py-akousma | |
| uv build --out-dir "$GITHUB_WORKSPACE/release/akousmata" akousmata | |
| uv build --out-dir "$GITHUB_WORKSPACE/release/oida" oida | |
| - name: Check distribution metadata | |
| run: uv run --project oida --extra dev twine check release/*/* | |
| - name: Verify Oída wheel in an isolated environment | |
| run: | | |
| cd "$RUNNER_TEMP" | |
| uv run --isolated --no-project \ | |
| --find-links "$GITHUB_WORKSPACE/release/akouo" \ | |
| --find-links "$GITHUB_WORKSPACE/release/akousma" \ | |
| --find-links "$GITHUB_WORKSPACE/release/akousmata" \ | |
| --with "$GITHUB_WORKSPACE"/release/oida/sonicfield_oida-*.whl \ | |
| python -c 'import oida, oida.server; print(oida.__version__)' | |
| - name: Upload verified distributions | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: python-distributions | |
| path: release | |
| if-no-files-found: error | |
| retention-days: 7 | |
| publish: | |
| name: Publish ${{ matrix.project }} to PyPI | |
| needs: build | |
| if: ${{ vars.PYPI_PUBLISH_ENABLED == 'true' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - project: akouo-contract | |
| directory: akouo | |
| environment: pypi | |
| - project: akousma | |
| directory: akousma | |
| environment: pypi-akousma | |
| - project: akousmata | |
| directory: akousmata | |
| environment: pypi-akousmata | |
| runs-on: ubuntu-latest | |
| environment: ${{ matrix.environment }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download verified distributions | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: python-distributions | |
| path: release | |
| - name: Publish ${{ matrix.project }} | |
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | |
| with: | |
| packages-dir: release/${{ matrix.directory }} | |
| skip-existing: true | |
| verify-metadata: true | |
| attestations: true | |
| publish-oida: | |
| name: Publish sonicfield-oida to PyPI | |
| needs: | |
| - build | |
| - publish | |
| if: ${{ vars.PYPI_PUBLISH_ENABLED == 'true' && vars.PYPI_OIDA_PUBLISH_ENABLED == 'true' }} | |
| runs-on: ubuntu-latest | |
| environment: pypi-sonicfield-oida | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download verified distributions | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: python-distributions | |
| path: release | |
| - name: Publish sonicfield-oida | |
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | |
| with: | |
| packages-dir: release/oida | |
| skip-existing: true | |
| verify-metadata: true | |
| attestations: true |