Skip to content

Commit 5fcca48

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

File tree

6 files changed

+515
-3
lines changed

6 files changed

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

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