|
1 | 1 | name: Build OpenCV Python wheel |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'opencv/*' |
5 | 7 |
|
6 | 8 | permissions: |
7 | | - contents: read |
| 9 | + contents: write |
8 | 10 |
|
9 | 11 | jobs: |
10 | | - |
11 | | - placeholder: |
| 12 | + build-wheels: |
12 | 13 | runs-on: ubuntu-24.04-arm |
| 14 | + container: |
| 15 | + image: debian:trixie |
| 16 | + options: --user root |
| 17 | + timeout-minutes: 180 |
| 18 | + |
13 | 19 | steps: |
14 | | - - name: Stub build step |
15 | | - run: echo "Actual build steps are defined in another branch." |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Install prerequisites |
| 24 | + run: | |
| 25 | + apt-get update |
| 26 | + apt-get install -y --no-install-recommends gh git ca-certificates build-essential pkg-config ninja-build |
| 27 | +
|
| 28 | + - name: Install Python |
| 29 | + run: | |
| 30 | + apt-get install -y --no-install-recommends python3 python3-dev python3-pip |
| 31 | +
|
| 32 | + - name: Install FFmpeg dependencies |
| 33 | + run: | |
| 34 | + apt-get install -y --no-install-recommends libavcodec-dev libavformat-dev libavutil-dev libswscale-dev |
| 35 | +
|
| 36 | + - name: Install Media I/O dependencies |
| 37 | + run: | |
| 38 | + apt-get install -y --no-install-recommends libjpeg62-turbo-dev libpng-dev libtiff-dev libwebp-dev libopenblas-dev liblapacke-dev |
| 39 | +
|
| 40 | + - name: Install GStreamer dependencies |
| 41 | + run: | |
| 42 | + apt-get install -y --no-install-recommends libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev |
| 43 | +
|
| 44 | + - name: Clone opencv-python repo |
| 45 | + run: | |
| 46 | + git clone --depth 1 https://github.com/opencv/opencv-python.git |
| 47 | + cd opencv-python |
| 48 | + git fetch --depth 1 origin 4ddfc013fd1f13d9b9e379dbebf2cdbeb052e7f8 |
| 49 | + git checkout 4ddfc013fd1f13d9b9e379dbebf2cdbeb052e7f8 |
| 50 | + git submodule update --init --recursive --depth 1 |
| 51 | +
|
| 52 | + - name: Build OpenCV Python wheels |
| 53 | + run: | |
| 54 | + cd opencv-python |
| 55 | + export OPENCV_VERSION=4.13.0 |
| 56 | + export ENABLE_CONTRIB=0 |
| 57 | + export ENABLE_HEADLESS=1 |
| 58 | + export CMAKE_ARGS="-DWITH_GSTREAMER=ON -DWITH_FFMPEG=ON -DWITH_CAROTENE=ON -DWITH_LAPACK=ON -DBUILD_opencv_python3=ON -DWITH_AVIF=OFF -DWITH_GTK=OFF -DWITH_QT=OFF -DWITH_CUDA=OFF -DBUILD_opencv_java=OFF -DWITH_VTK=OFF -DBUILD_opencv_dnn=OFF -DBUILD_opencv_dnn_modern=OFF" |
| 59 | + pip3 wheel . --verbose --no-deps |
| 60 | +
|
| 61 | + - name: Upload wheel files |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: opencv-python-wheels |
| 65 | + path: opencv-python/*.whl |
| 66 | + |
| 67 | + - name: Determine version |
| 68 | + id: version |
| 69 | + run: | |
| 70 | + # Extract version from tag (opencv/4.13.0 -> 4.13.0) |
| 71 | + VERSION="${GITHUB_REF#refs/tags/opencv/}" |
| 72 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 73 | + echo "Release version: $VERSION" |
| 74 | +
|
| 75 | + - name: Create or update release |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + run: | |
| 79 | + VERSION="${{ steps.version.outputs.version }}" |
| 80 | + TAG="opencv/$VERSION" |
| 81 | + REPO="${{ github.repository }}" |
| 82 | + |
| 83 | + # Delete release if it already exists |
| 84 | + if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then |
| 85 | + echo "Release $TAG already exists. Deleting..." |
| 86 | + gh release delete "$TAG" --repo "$REPO" --yes |
| 87 | + fi |
| 88 | +
|
| 89 | + # Create release |
| 90 | + gh release create "$TAG" \ |
| 91 | + opencv-python/opencv_python_headless*.whl \ |
| 92 | + --repo "$REPO" \ |
| 93 | + --latest=false \ |
| 94 | + --title "opencv-python-headless $VERSION" \ |
| 95 | + --notes "OpenCV Python headless wheel version $VERSION optimized for ARM64 architecture with GStreamer and FFmpeg support." |
0 commit comments