Merge pull request #728 from google/py-build-and-upload-packages #14
This file contains 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: Python - build and upload packages | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'python-v*' | |
# We don't nned to create artifacts for each PR, but this makes it much | |
# easier to test this workflow. Remove comments when needed. | |
# pull_request: | |
# paths: | |
# - 'python/**' | |
# - 'rust/**' | |
# - 'tests_data/**' | |
# - '.github/workflows/**' | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: ${{ matrix.conf.name }} | |
runs-on: ${{ matrix.conf.runner }} | |
strategy: | |
matrix: | |
conf: | |
- name: linux | |
runner: ubuntu-latest | |
- name: windows | |
runner: windows-latest | |
- name: macos | |
runner: macos-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v4 | |
- name: Setup Python | |
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # pin@v5 | |
with: | |
python-version-file: 'python/.python-version' | |
- name: Install uv | |
run: curl -LsSf https://astral.sh/uv/0.4.7/install.sh | sh | |
# It's OK to use the default python version and not the specified one | |
- name: Install all projects dependencies | |
working-directory: python | |
run: uv sync --all-extras --dev | |
- name: Build the python package | |
working-directory: python | |
run: uv run ./scripts/build_python_package.py | |
- name: List wheels | |
working-directory: python | |
run: python -c "import os; print('\n'.join(os.listdir('dist')))" | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-${{ matrix.conf.name }} | |
path: python/dist/*.whl | |
# We upload the source tarball only for linux as it's the same for the | |
# other platforms. | |
- name: Upload source tarball | |
if: ${{ matrix.conf.name == 'linux' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: source-tarball | |
path: python/dist/*.tar.gz |