Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a [reusable] workflow for building wheels #42

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/reusable-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Reusable action which builds struct2tensor

peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
inputs:
python-version:
description: 'Python version'
required: true
runs:
using: 'composite'
steps:
- name: Build the package for Python ${{ inputs.python-version }}
shell: bash
run: |
docker compose build --build-arg PYTHON_VERSION=${{ inputs.python-version }} manylinux2014
docker compose run -e TF_VERSION=RELEASED_TF_2 manylinux2014
bazel build -c opt struct2tensor:struct2tensor_kernels_and_ops
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload wheel artifact for Python ${{ inputs.python-version }}
uses: actions/upload-artifact@v4
with:
name: ml-metadata-wheel-py${{ inputs.python-version }}
path: dist/*.whl
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build struct2tensor wheels

on:
pull_request:
workflow_dispatch:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build package
id: build-package
uses: ./.github/reusable-build
with:
python-version: ${{ matrix.python-version }}

- name: Retrieve wheels
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: wheels
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: List and check wheels
shell: bash
run: |
pip install twine pkginfo>=1.10.0
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
${{ matrix.ls || 'ls -lh' }} wheels/
twine check wheels/*


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')
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/struct2tensor/
permissions:
id-token: write
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Retrieve wheels
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: wheels

- name: List the build artifacts
run: |
ls -lAs wheels/

peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
peytondmurray marked this conversation as resolved.
Show resolved Hide resolved
with:
packages_dir: wheels/
1 change: 1 addition & 0 deletions bazel-bin
1 change: 1 addition & 0 deletions bazel-out
1 change: 1 addition & 0 deletions bazel-struct2tensor
1 change: 1 addition & 0 deletions bazel-testlogs
Binary file not shown.