Skip to content

Commit b485d4f

Browse files
committed
Add a [reusable] workflow for building wheels
1 parent 4ce8b46 commit b485d4f

File tree

7 files changed

+94
-0
lines changed

7 files changed

+94
-0
lines changed

.github/reusable-build/action.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Reusable action which builds struct2tensor
2+
3+
inputs:
4+
python-version:
5+
description: 'Python version'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Build the package for Python ${{ inputs.python-version }}
11+
shell: bash
12+
run: |
13+
docker compose build --build-arg PYTHON_VERSION=${{ inputs.python-version }} manylinux2014
14+
docker compose run -e TF_VERSION=RELEASED_TF_2 manylinux2014
15+
bazel build -c opt struct2tensor:struct2tensor_kernels_and_ops
16+
17+
- name: Upload wheel artifact for Python ${{ inputs.python-version }}
18+
uses: actions/upload-artifact@v4
19+
with:
20+
name: ml-metadata-wheel-py${{ inputs.python-version }}
21+
path: dist/*.whl

.github/workflows/build.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build struct2tensor wheels
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11"]
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Build package
21+
id: build-package
22+
uses: ./.github/reusable-build
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Retrieve wheels
27+
uses: actions/download-artifact@v4
28+
with:
29+
merge-multiple: true
30+
path: wheels
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: List and check wheels
38+
shell: bash
39+
run: |
40+
pip install twine pkginfo>=1.10.0
41+
${{ matrix.ls || 'ls -lh' }} wheels/
42+
twine check wheels/*
43+
44+
45+
upload_to_pypi:
46+
name: Upload to PyPI
47+
runs-on: ubuntu-latest
48+
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
49+
needs: [build]
50+
environment:
51+
name: pypi
52+
url: https://pypi.org/p/struct2tensor/
53+
permissions:
54+
id-token: write
55+
steps:
56+
- name: Retrieve wheels
57+
uses: actions/download-artifact@v4
58+
with:
59+
merge-multiple: true
60+
path: wheels
61+
62+
- name: List the build artifacts
63+
run: |
64+
ls -lAs wheels/
65+
66+
- name: Upload to PyPI
67+
uses: pypa/gh-action-pypi-publish@release/v1.9
68+
with:
69+
packages_dir: wheels/

bazel-bin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.cache/bazel/_bazel_root/dc79bfaee0f4e290b3fb72a6e9cdf460/execroot/struct2tensor/bazel-out/k8-opt/bin

bazel-out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.cache/bazel/_bazel_root/dc79bfaee0f4e290b3fb72a6e9cdf460/execroot/struct2tensor/bazel-out

bazel-struct2tensor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.cache/bazel/_bazel_root/dc79bfaee0f4e290b3fb72a6e9cdf460/execroot/struct2tensor

bazel-testlogs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.cache/bazel/_bazel_root/dc79bfaee0f4e290b3fb72a6e9cdf460/execroot/struct2tensor/bazel-out/k8-opt/testlogs
1.83 MB
Binary file not shown.

0 commit comments

Comments
 (0)