Skip to content

build: enable macOS CI, add Python 3.13, and stabilize Bazel configuration #24

build: enable macOS CI, add Python 3.13, and stabilize Bazel configuration

build: enable macOS CI, add Python 3.13, and stabilize Bazel configuration #24

Workflow file for this run

name: Build Wheels & Publish to PyPI
on:
pull_request:
workflow_dispatch:
release:
types: [published]
env:
USE_BAZEL_VERSION: "6.5.0"
jobs:
build:
name: >
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
${{ (matrix.arch) || '' }}
strategy:
# fail-fast: true
matrix:
os: [ubuntu, macos]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
runs-on: ${{ format('{0}-latest', matrix.os) }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install python build dependencies
run: |
python -m pip install --upgrade pip "setuptools<70" "build<2.0" wheel
- name: Install Bazel
run: |
mkdir -p ~/.local/bin
if [[ "${{ runner.os }}" == "Linux" ]]; then
wget --no-check-certificate -q https://github.com/bazelbuild/bazel/releases/download/${{ env.USE_BAZEL_VERSION }}/bazel-${{ env.USE_BAZEL_VERSION }}-linux-x86_64 -O ~/.local/bin/bazel
elif [[ "${{ runner.os }}" == "macOS" ]]; then
wget --no-check-certificate -q https://github.com/bazelbuild/bazel/releases/download/${{ env.USE_BAZEL_VERSION }}/bazel-${{ env.USE_BAZEL_VERSION }}-darwin-arm64 -O ~/.local/bin/bazel
fi
chmod +x ~/.local/bin/bazel
echo "$HOME/.local/bin" >> $GITHUB_PATH
bazel --version
- name: Build wheels
run: |
python -m build --wheel --sdist
mkdir wheelhouse
mv dist/* wheelhouse/
- name: List and check wheels
run: |
pip install twine pkginfo>=1.11.0
${{ matrix.ls || 'ls -lh' }} wheelhouse/
twine check wheelhouse/*
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.python-version }}-${{ matrix.os }}
path: ./wheelhouse/*
upload_to_pypi:
name: Upload to PyPI
runs-on: ubuntu-latest
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/tensorflow-metadata
permissions:
id-token: write
steps:
- name: Retrieve wheels and sdist
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: wheels/
- name: List the build artifacts
run: |
ls -lAs wheels/
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.12
with:
packages-dir: wheels/
# already checked, and the pkginfo/twine versions on this runner causes check to fail
verify-metadata: false
verbose: true