Skip to content

Commit 9735c62

Browse files
feat: 添加自定义构建模板
1 parent dea58ae commit 9735c62

File tree

6 files changed

+518
-3
lines changed

6 files changed

+518
-3
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: Build manywheel docker images (custom)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Build with specific tag'
8+
required: false
9+
default: ''
10+
11+
jobs:
12+
check_version:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.check_version.outputs.version }}
16+
steps:
17+
- name: Check version
18+
id: check_version
19+
run: |
20+
if [ -z "${{ github.event.inputs.tag }}" ]; then
21+
echo "No tag provided, using latest release"
22+
version=$(curl -s "https://api.github.com/repos/opencv/opencv-python/releases/latest" | jq -r .tag_name)
23+
else
24+
version=${{ github.event.inputs.tag }}
25+
fi
26+
27+
if [ -z "${version}" ] || [ "${version}" == "null" ]; then
28+
echo "Failed to get version"
29+
exit 1
30+
fi
31+
32+
echo "version=${version}" >> $GITHUB_ENV
33+
echo "version=${version}" >> $GITHUB_OUTPUT
34+
echo ""
35+
echo "========== Build Args =========="
36+
echo "opencv-python version: ${version}"
37+
38+
build_loongarch64_manylinux:
39+
name: Build image for loongarch64
40+
runs-on: ubuntu-latest
41+
needs: check_version
42+
env:
43+
version: ${{ needs.check_version.outputs.version }}
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: docker/setup-qemu-action@v3
47+
- uses: docker/setup-buildx-action@v3
48+
49+
- name: Generate files
50+
run: |
51+
mkdir -p docker/manylinux_2_38
52+
wget -qO docker/manylinux_2_38/Dockerfile_loongarch64 https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_x86_64
53+
patch -p1 < loong64.patch
54+
cd docker/manylinux_2_38
55+
sed -i "s@FROM quay.io/pypa/manylinux2014_x86_64@FROM ghcr.io/loong64/manylinux_2_38_loongarch64@g" Dockerfile_loongarch64
56+
image_tag=$(cat Dockerfile_loongarch64 | grep "Version:" | sed 's/# Version: //')
57+
echo "image_tag=${image_tag}" >> $GITHUB_ENV
58+
59+
- name: Login to GitHub Container Registry
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.repository_owner }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Build and push image
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: .
70+
file: docker/manylinux_2_38/Dockerfile_loongarch64
71+
platforms: linux/loong64
72+
push: true
73+
tags: |
74+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux_2_38-loongarch64:${{ env.image_tag }}
75+
cache-from: |
76+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux_2_38-loongarch64:${{ env.image_tag }}
77+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux_2_38-loongarch64:latest
78+
79+
build_ppc64le_manylinux:
80+
name: Build image for ppc64le
81+
runs-on: ubuntu-latest
82+
needs: check_version
83+
env:
84+
version: ${{ needs.check_version.outputs.version }}
85+
steps:
86+
- uses: actions/checkout@v4
87+
- uses: docker/setup-qemu-action@v3
88+
- uses: docker/setup-buildx-action@v3
89+
90+
- name: Generate files
91+
run: |
92+
mkdir -p docker/manylinux2014
93+
wget -qO docker/manylinux2014/Dockerfile_ppc64le https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_x86_64
94+
patch -p1 < ppc64le.patch
95+
cd docker/manylinux2014
96+
sed -i "s@FROM quay.io/pypa/manylinux2014_x86_64@FROM quay.io/pypa/manylinux2014_ppc64le@g" Dockerfile_ppc64le
97+
image_tag=$(cat Dockerfile_ppc64le | grep "Version:" | sed 's/# Version: //')
98+
echo "image_tag=${image_tag}" >> $GITHUB_ENV
99+
100+
- name: Login to GitHub Container Registry
101+
uses: docker/login-action@v3
102+
with:
103+
registry: ghcr.io
104+
username: ${{ github.repository_owner }}
105+
password: ${{ secrets.GITHUB_TOKEN }}
106+
107+
- name: Build and push image
108+
uses: docker/build-push-action@v6
109+
with:
110+
context: .
111+
file: docker/manylinux2014/Dockerfile_ppc64le
112+
platforms: linux/ppc64le
113+
push: true
114+
tags: |
115+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-ppc64le:${{ env.image_tag }}
116+
cache-from: |
117+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-ppc64le:${{ env.image_tag }}
118+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-ppc64le:latest
119+
120+
build_s390x_manylinux:
121+
name: Build image for s390x
122+
runs-on: ubuntu-latest
123+
needs: check_version
124+
env:
125+
version: ${{ needs.check_version.outputs.version }}
126+
steps:
127+
- uses: actions/checkout@v4
128+
- uses: docker/setup-qemu-action@v3
129+
- uses: docker/setup-buildx-action@v3
130+
131+
- name: Generate files
132+
run: |
133+
mkdir -p docker/manylinux2014
134+
wget -qO docker/manylinux2014/Dockerfile_s390x https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_x86_64
135+
patch -p1 < s390x.patch
136+
cd docker/manylinux2014
137+
sed -i "s@FROM quay.io/pypa/manylinux2014_x86_64@FROM quay.io/pypa/manylinux2014_s390x@g" Dockerfile_s390x
138+
image_tag=$(cat Dockerfile_s390x | grep "Version:" | sed 's/# Version: //')
139+
echo "image_tag=${image_tag}" >> $GITHUB_ENV
140+
141+
- name: Login to GitHub Container Registry
142+
uses: docker/login-action@v3
143+
with:
144+
registry: ghcr.io
145+
username: ${{ github.repository_owner }}
146+
password: ${{ secrets.GITHUB_TOKEN }}
147+
148+
- name: Build and push image
149+
uses: docker/build-push-action@v6
150+
with:
151+
context: .
152+
file: docker/manylinux2014/Dockerfile_s390x
153+
platforms: linux/s390x
154+
push: true
155+
tags: |
156+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-s390x:${{ env.image_tag }}
157+
cache-from: |
158+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-s390x:${{ env.image_tag }}
159+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-s390x:latest

.github/workflows/build-manywheel-images.yml renamed to .github/workflows/build-manylinux-images.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: 0 0 * * *
77

88
jobs:
9-
build_loongarch64_wheels:
9+
build_loongarch64_manylinux:
1010
name: Build image for loongarch64
1111
runs-on: ubuntu-latest
1212
steps:
@@ -80,6 +80,7 @@ jobs:
8080
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8181

8282
- name: Release
83+
if: env.build == '1'
8384
uses: softprops/action-gh-release@v2
8485
with:
8586
repository: ${{ github.repository }}

.github/workflows/build_wheels_linux.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
echo "========== Build Args =========="
2929
echo "opencv-python version: ${version}"
3030
31-
gh release view ${version} -R ${{ github.repository }} | grep opencv.*.whl >/dev/null 2>&1 || echo "build=1" >> $GITHUB_ENV
31+
gh release view ${version} -R ${{ github.repository }} | grep opencv.*.whl >/dev/null 2>&1 || echo "build=1" >> $GITHUB_OUTPUT
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434

@@ -80,6 +80,8 @@ jobs:
8080
uses: docker/setup-qemu-action@v3
8181
- name: Build a package
8282
run: source scripts/build.sh
83+
env:
84+
DOCKER_DEFAULT_PLATFORM: linux/loong64
8385
- name: Saving a wheel accordingly to matrix
8486
uses: actions/upload-artifact@v4
8587
with:
@@ -98,10 +100,12 @@ jobs:
98100
steps:
99101
- uses: actions/download-artifact@v4
100102
with:
101-
name: wheels
103+
pattern: wheel-*
102104
path: wheelhouse/
105+
merge-multiple: true
103106
- name: Upload wheels
104107
run: |
108+
ls -al wheelhouse/
105109
pip install twine==6.0.1
106110
for file in wheelhouse/*.whl; do
107111
twine upload --repository-url https://gitlab.com/api/v4/projects/65746188/packages/pypi $file || true

0 commit comments

Comments
 (0)