Skip to content

Commit 4bbb721

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

File tree

4 files changed

+363
-3
lines changed

4 files changed

+363
-3
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
76+
build_ppc64le_manylinux:
77+
name: Build image for ppc64le
78+
runs-on: ubuntu-latest
79+
needs: check_version
80+
env:
81+
version: ${{ needs.check_version.outputs.version }}
82+
steps:
83+
- uses: actions/checkout@v4
84+
- uses: docker/setup-qemu-action@v3
85+
- uses: docker/setup-buildx-action@v3
86+
87+
- name: Generate files
88+
run: |
89+
mkdir -p docker/manylinux2014
90+
wget -qO docker/manylinux2014/Dockerfile_ppc64le https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_x86_64
91+
cd docker/manylinux2014
92+
sed -i "s@FROM quay.io/pypa/manylinux2014_x86_64@FROM quay.io/pypa/manylinux2014_ppc64le@g" Dockerfile_ppc64le
93+
image_tag=$(cat Dockerfile_ppc64le | grep "Version:" | sed 's/# Version: //')
94+
echo "image_tag=${image_tag}" >> $GITHUB_ENV
95+
96+
- name: Login to GitHub Container Registry
97+
uses: docker/login-action@v3
98+
with:
99+
registry: ghcr.io
100+
username: ${{ github.repository_owner }}
101+
password: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Build and push image
104+
uses: docker/build-push-action@v6
105+
with:
106+
context: .
107+
file: docker/manylinux2014/Dockerfile_ppc64le
108+
platforms: linux/ppc64le
109+
push: true
110+
tags: |
111+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-ppc64le:${{ env.image_tag }}
112+
113+
build_s390x_manylinux:
114+
name: Build image for s390x
115+
runs-on: ubuntu-latest
116+
needs: check_version
117+
env:
118+
version: ${{ needs.check_version.outputs.version }}
119+
steps:
120+
- uses: actions/checkout@v4
121+
- uses: docker/setup-qemu-action@v3
122+
- uses: docker/setup-buildx-action@v3
123+
124+
- name: Generate files
125+
run: |
126+
mkdir -p docker/manylinux2014
127+
wget -qO docker/manylinux2014/Dockerfile_s390x https://github.com/opencv/opencv-python/raw/refs/tags/${version}/docker/manylinux2014/Dockerfile_x86_64
128+
cd docker/manylinux2014
129+
sed -i "s@FROM quay.io/pypa/manylinux2014_x86_64@FROM quay.io/pypa/manylinux2014_s390x@g" Dockerfile_s390x
130+
image_tag=$(cat Dockerfile_s390x | grep "Version:" | sed 's/# Version: //')
131+
echo "image_tag=${image_tag}" >> $GITHUB_ENV
132+
133+
- name: Login to GitHub Container Registry
134+
uses: docker/login-action@v3
135+
with:
136+
registry: ghcr.io
137+
username: ${{ github.repository_owner }}
138+
password: ${{ secrets.GITHUB_TOKEN }}
139+
140+
- name: Build and push image
141+
uses: docker/build-push-action@v6
142+
with:
143+
context: .
144+
file: docker/manylinux2014/Dockerfile_s390x
145+
platforms: linux/s390x
146+
push: true
147+
tags: |
148+
ghcr.io/${{ github.repository_owner }}/opencv-python-manylinux2014-s390x:${{ env.image_tag }}

.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)