SpliSplit wheel upload and PyPI publish into separate optimized jobs so all matrix runners build wheels and a unified Linux job publishes them to PyPI #132
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: Build | |
| on: | |
| push: | |
| branches: [ master, 'r*' ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ master, 'r*' ] | |
| env: | |
| USE_BAZEL_VERSION: 7.7.0 | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.os }}, Python ${{ matrix.python-version }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up conda environment | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-activate-base: false | |
| activate-environment: s2t-env | |
| environment-file: environment.yml | |
| python-version: ${{ matrix.python-version }} | |
| use-mamba: true | |
| - name: Install Bazel | |
| shell: bash -l {0} | |
| run: | | |
| # Install Bazelisk (manages Bazel versions) | |
| if [ "$RUNNER_OS" == "Linux" ]; then | |
| curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 | |
| elif [ "$RUNNER_OS" == "macOS" ]; then | |
| ARCH=$(uname -m) | |
| if [ "$ARCH" == "arm64" ]; then | |
| curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-arm64 | |
| else | |
| curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64 | |
| fi | |
| fi | |
| chmod +x /tmp/bazelisk | |
| sudo mv /tmp/bazelisk /usr/local/bin/bazel | |
| - name: Configure Bazel | |
| shell: bash -l {0} | |
| run: | | |
| ./configure.sh | |
| bazel --version | |
| - name: Patch Apple CC toolchain (macOS only) | |
| if: runner.os == 'macOS' | |
| shell: bash -l {0} | |
| run: bazel build //:patch_local_config_apple_cc | |
| - name: Build struct2tensor | |
| shell: bash -l {0} | |
| run: bazel build //struct2tensor:path --verbose_failures | |
| - name: Build all targets | |
| if: runner.os == 'Linux' | |
| shell: bash -l {0} | |
| run: bazel build //... | |
| - name: Build Release Wheel | |
| shell: bash -l {0} | |
| run: bazel run //:build_pip_package | |
| - name: Upload Wheel Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ matrix.python-version }} | |
| path: dist/*.whl | |
| docker-serving-build: | |
| name: Build Docker Serving Image | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Pre-pull Ubuntu base image from GCR mirror to prevent Docker Hub timeouts | |
| run: | | |
| docker pull mirror.gcr.io/library/ubuntu:22.04 | |
| docker tag mirror.gcr.io/library/ubuntu:22.04 ubuntu:22.04 | |
| - name: Build TF-Serving Docker Image | |
| run: | | |
| cd struct2tensor/tools/tf_serving_docker | |
| docker build -t struct2tensor-serving:latest . | |
| pypi-publish: | |
| name: Publish Wheels to PyPI | |
| needs: build | |
| if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/r')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Publish Package to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| packages-dir: dist/ | |
| skip-existing: true |