name: Python SDK Wheels on: workflow_dispatch: inputs: publish: description: "Publish wheels to PyPI after building" required: true default: false type: boolean permissions: contents: read id-token: write jobs: build-wheels: name: Build wheel (${{ matrix.name }}) runs-on: ${{ matrix.os }} container: ${{ matrix.container || null }} strategy: fail-fast: false matrix: include: - name: macos-arm64 os: macos-14 - name: macos-x86_64 os: macos-13 - name: linux-x86_64 os: ubuntu-latest container: quay.io/pypa/manylinux_2_28_x86_64@sha256:441c35fdc6ee809ff9260894f8468ab4fea8c15dc880f8700a3f81b7922c1cda - name: windows-x86_64 os: windows-latest steps: - name: Checkout code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Set up Rust uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 - name: Set up Python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 with: python-version: "3.12" - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 with: enable-cache: true - name: Install Linux tools if: runner.os == 'Linux' shell: bash run: | python3 -m pip install --upgrade pip python3 -m pip install uv echo "$HOME/.local/bin" >> "$GITHUB_PATH" curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin - name: Install just if: runner.os != 'Linux' uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 - name: Cache Cargo artifacts uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 - name: Build wheel shell: bash run: just --justfile crates/goose-sdk/justfile python-wheel - name: Repair Linux wheel if: runner.os == 'Linux' shell: bash run: | python3 -m pip install auditwheel mkdir -p crates/goose-sdk/python/wheelhouse auditwheel repair --plat manylinux_2_28_x86_64 -w crates/goose-sdk/python/wheelhouse crates/goose-sdk/python/dist/*.whl rm crates/goose-sdk/python/dist/*.whl mv crates/goose-sdk/python/wheelhouse/*.whl crates/goose-sdk/python/dist/ - name: Smoke test wheel shell: bash run: | python -m venv .venv-wheel-test if [ "${{ runner.os }}" = "Windows" ]; then python_bin=".venv-wheel-test/Scripts/python.exe" else python_bin=".venv-wheel-test/bin/python" fi UV_NO_CONFIG=1 uv pip install --default-index https://pypi.org/simple --python "$python_bin" crates/goose-sdk/python/dist/*.whl "$python_bin" -c 'import goose; print(goose.__name__)' - name: Upload wheel artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: goose-sdk-wheel-${{ matrix.name }} path: crates/goose-sdk/python/dist/*.whl if-no-files-found: error publish: name: Publish wheels to PyPI needs: build-wheels runs-on: ubuntu-latest if: github.event_name == 'workflow_dispatch' && inputs.publish environment: pypi steps: - name: Download wheel artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: pattern: goose-sdk-wheel-* path: dist merge-multiple: true - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 with: packages-dir: dist