Skip to content

Commit 11df3ed

Browse files
committed
Move build_bin_wheels into its own module so that we can share.
1 parent 3b1f18e commit 11df3ed

File tree

2 files changed

+96
-76
lines changed

2 files changed

+96
-76
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -77,82 +77,7 @@ jobs:
7777

7878
build_bin_wheels:
7979
needs: build_and_test_python
80-
runs-on: ubuntu-latest
81-
permissions:
82-
packages: write
83-
env:
84-
PY_VER: ${{ matrix.python-version }}
85-
BASE_IMAGE: quay.io/pypa/manylinux_${{ matrix.mnl-version }}:latest
86-
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
87-
strategy:
88-
fail-fast: false
89-
matrix:
90-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
91-
mnl-version: ['2_28', '2_34']
92-
steps:
93-
- name: Set up Python ${{ env.PY_VER }}
94-
uses: actions/setup-python@v5
95-
with:
96-
python-version: ${{ env.PY_VER }}
97-
98-
- uses: actions/checkout@v4
99-
100-
- name: Set up QEMU
101-
uses: docker/setup-qemu-action@v3
102-
103-
- name: Set up Docker Buildx
104-
uses: docker/setup-buildx-action@v3
105-
106-
- name: Login to GitHub Container Registry
107-
uses: docker/login-action@v3
108-
if: github.event_name != 'pull_request'
109-
with:
110-
registry: ghcr.io
111-
username: ${{ github.repository_owner }}
112-
password: ${{ secrets.GITHUB_TOKEN }}
113-
114-
- name: Set dynamic environment
115-
id: set-env
116-
run: |
117-
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
118-
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
119-
sort -u | grep -v unknown | paste -sd ','`"
120-
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
121-
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
122-
BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}-mnl${{ matrix.mnl-version }}"
123-
test "${{ github.event_name }}" != 'pull_request' && \
124-
CACHE_SPEC="type=registry,ref=${BUILD_IMAGE}-buildcache" || \
125-
CACHE_SPEC="gha"
126-
echo "Platforms: ${PLATFORMS}"
127-
echo "Build Image: ${BUILD_IMAGE}"
128-
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
129-
echo "CACHE_SPEC=${CACHE_SPEC}" >> $GITHUB_ENV
130-
131-
- name: Build Binary Wheels
132-
uses: docker/build-push-action@v6
133-
with:
134-
context: .
135-
file: ./docker/Dockerfile.python_wheels
136-
build-args: |
137-
BASE_IMAGE=${{ env.BASE_IMAGE }}
138-
PY_VER=${{ env.PY_VER }}
139-
platforms: ${{ env.PLATFORMS }}
140-
push: false
141-
outputs: type=local,dest=dist_out
142-
cache-from: ${{ env.CACHE_SPEC }}
143-
cache-to: ${{ env.CACHE_SPEC }},mode=max
144-
145-
- name: Collect Wheels
146-
run: |
147-
mkdir dist
148-
mv `find dist_out -type f -name \*.whl` dist
149-
rm -r dist_out
150-
151-
- name: Upload built wheels
152-
uses: actions/upload-artifact@v4
153-
with:
154-
name: dist-py${{ env.PY_VER }}-mnl${{ matrix.mnl-version }}
155-
path: dist
80+
uses: sippy/libasyncproxy/actions/BuildPythonWheels.yml@wip
15681

15782
publish_pypi:
15883
needs: build_bin_wheels
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: 'Wheel Builder'
2+
description: 'Build Binary wheels for a Python project'
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
dockerfile:
8+
description: 'Dockerfile to use'
9+
required: false
10+
default: './docker/Dockerfile.python_wheels'
11+
context:
12+
description: 'Context to pass into container'
13+
required: false
14+
default: '.'
15+
py_versions:
16+
description: 'Versions of Python to build against'
17+
required: false
18+
default: ['3.8', '3.9', '3.10', '3.11', '3.12']
19+
20+
jobs:
21+
build_bin_wheels:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
packages: write
25+
env:
26+
PY_VER: ${{ matrix.python-version }}
27+
BASE_IMAGE: quay.io/pypa/manylinux_${{ matrix.mnl-version }}:latest
28+
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
python-version: ${{ inputs.py_versions }}
33+
mnl-version: ['2_28', '2_34']
34+
steps:
35+
- name: Set up Python ${{ env.PY_VER }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ env.PY_VER }}
39+
40+
- name: Set up QEMU
41+
uses: docker/setup-qemu-action@v3
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
46+
- name: Login to GitHub Container Registry
47+
uses: docker/login-action@v3
48+
if: github.event_name != 'pull_request'
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.repository_owner }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Set dynamic environment
55+
id: set-env
56+
run: |
57+
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
58+
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
59+
sort -u | grep -v unknown | paste -sd ','`"
60+
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
61+
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
62+
BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}-mnl${{ matrix.mnl-version }}"
63+
test "${{ github.event_name }}" != 'pull_request' && \
64+
CACHE_SPEC="type=registry,ref=${BUILD_IMAGE}-buildcache" || \
65+
CACHE_SPEC="gha"
66+
echo "Platforms: ${PLATFORMS}"
67+
echo "Build Image: ${BUILD_IMAGE}"
68+
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
69+
echo "CACHE_SPEC=${CACHE_SPEC}" >> $GITHUB_ENV
70+
71+
- name: Build Binary Wheels
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: ${{ inputs.context }}
75+
file: ${{ inputs.dockerfile }}
76+
build-args: |
77+
BASE_IMAGE=${{ env.BASE_IMAGE }}
78+
PY_VER=${{ env.PY_VER }}
79+
platforms: ${{ env.PLATFORMS }}
80+
push: false
81+
outputs: type=local,dest=dist_out
82+
cache-from: ${{ env.CACHE_SPEC }}
83+
cache-to: ${{ env.CACHE_SPEC }},mode=max
84+
85+
- name: Collect Wheels
86+
run: |
87+
mkdir dist
88+
mv `find dist_out -type f -name \*.whl` dist
89+
rm -r dist_out
90+
91+
- name: Upload Wheels
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: dist-py${{ env.PY_VER }}-mnl${{ matrix.mnl-version }}
95+
path: dist

0 commit comments

Comments
 (0)