-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6892 from peytondmurray/5-build-workflow
Add a workflow to build wheels and (only on release) publish to PyPI
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: Build Wheels & Publish to PyPI | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
USE_BAZEL_VERSION: "7.2.1" | ||
|
||
jobs: | ||
build_sdist: | ||
name: Build sdist | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: install python dependencies | ||
run: pip install build twine | ||
|
||
- name: build sdist | ||
run: | | ||
python -m build --sdist -o wheelhouse | ||
- name: List and check sdist | ||
run: | | ||
ls -lh wheelhouse/ | ||
twine check wheelhouse/* | ||
- name: Upload sdist | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sdist | ||
path: ./wheelhouse/*.tar.gz | ||
|
||
build_wheels: | ||
name: > | ||
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} | ||
${{ (matrix.arch) || '' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu] | ||
python-version: ['cp39', 'cp310'] | ||
|
||
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: '3.10' | ||
|
||
- name: Install python build dependencies | ||
run: | | ||
pip install wheel | ||
- uses: bazel-contrib/[email protected] | ||
name: Set up Bazel | ||
with: | ||
# Avoid downloading Bazel every time. | ||
bazelisk-cache: true | ||
# Store build cache per workflow. | ||
disk-cache: ${{ github.workflow }}-${{ hashFiles('.github/workflows/wheels.yml') }} | ||
# Share repository cache between workflows. | ||
repository-cache: true | ||
|
||
- name: Verify bazel installation | ||
run: | | ||
which bazel | ||
bazel info | ||
bazel version | ||
- name: Build wheels | ||
run: | | ||
package_build/initialize.sh | ||
python package_build/tfx/setup.py bdist_wheel | ||
python package_build/ml-pipelines-sdk/setup.py bdist_wheel | ||
mkdir wheelhouse | ||
mv dist/*.whl wheelhouse/ | ||
- name: List and check wheels | ||
run: | | ||
pip install twine pkginfo>=1.10.0 | ||
${{ matrix.ls || 'ls -lh' }} wheelhouse/ | ||
twine check wheelhouse/* | ||
- name: Upload wheels | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-${{ matrix.python-version }}-${{ matrix.os }} | ||
path: ./wheelhouse/*.whl | ||
|
||
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_wheels, build_sdist] | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/tfx | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Retrieve wheels and sdist | ||
uses: actions/download-artifact@v4 | ||
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.9 | ||
with: | ||
packages_dir: wheels/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,3 +141,6 @@ bazel-* | |
**/*_pb2.py | ||
**/*_pb2_grpc.py | ||
# LINT.ThenChange(.dockerignore) | ||
|
||
MODULE.bazel | ||
MODULE.bazel.lock |