|
| 1 | +name: Build layers |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + NUMPY_VERSION: "2.5.4" |
| 11 | + |
| 12 | +jobs: |
| 13 | + # cv2 is built with the Python Limited API, so one build per |
| 14 | + # (OpenCV, profile, arch) serves every Python >= 3.12. |
| 15 | + opencv: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + opencv: ["4.14.0", "5.1.0"] |
| 20 | + profile: [minimal, standard, dnn] |
| 21 | + arch: [x86_64, arm64] |
| 22 | + runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - run: ./build.sh 3.12 ${{ matrix.arch }} opencv ${{ matrix.opencv }} ${{ matrix.profile }} |
| 26 | + - uses: actions/upload-artifact@v4 |
| 27 | + with: |
| 28 | + name: opencv-${{ matrix.opencv }}-${{ matrix.profile }}-${{ matrix.arch }} |
| 29 | + path: artifacts/*.tar.gz |
| 30 | + if-no-files-found: error |
| 31 | + |
| 32 | + numpy: |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + python: ["3.12", "3.13", "3.14"] |
| 37 | + arch: [x86_64, arm64] |
| 38 | + runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + - run: ./build.sh ${{ matrix.python }} ${{ matrix.arch }} numpy ${{ env.NUMPY_VERSION }} |
| 42 | + - uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: numpy-${{ matrix.python }}-${{ matrix.arch }} |
| 45 | + path: artifacts/*.tar.gz |
| 46 | + if-no-files-found: error |
| 47 | + |
| 48 | + # Smoke-test and zip inside each target runtime. |
| 49 | + package: |
| 50 | + needs: [opencv, numpy] |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + python: ["3.12", "3.13", "3.14"] |
| 55 | + arch: [x86_64, arm64] |
| 56 | + runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + - uses: actions/download-artifact@v4 |
| 60 | + with: |
| 61 | + pattern: opencv-*-${{ matrix.arch }} |
| 62 | + path: artifacts |
| 63 | + merge-multiple: true |
| 64 | + - uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + name: numpy-${{ matrix.python }}-${{ matrix.arch }} |
| 67 | + path: artifacts |
| 68 | + - run: ./build.sh ${{ matrix.python }} ${{ matrix.arch }} package |
| 69 | + - uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: layers-${{ matrix.python }}-${{ matrix.arch }} |
| 72 | + path: dist/* |
| 73 | + if-no-files-found: error |
| 74 | + |
| 75 | + # Single required status check for branch protection. Fails if any job |
| 76 | + # failed, was cancelled, or was skipped because an earlier stage failed. |
| 77 | + result: |
| 78 | + name: CI result |
| 79 | + if: always() |
| 80 | + needs: [opencv, numpy, package] |
| 81 | + runs-on: ubuntu-24.04 |
| 82 | + steps: |
| 83 | + - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') |
| 84 | + run: exit 1 |
| 85 | + - run: echo "all jobs passed" |
| 86 | + |
| 87 | + release: |
| 88 | + if: startsWith(github.ref, 'refs/tags/v') |
| 89 | + needs: package |
| 90 | + runs-on: ubuntu-24.04 |
| 91 | + permissions: |
| 92 | + contents: write |
| 93 | + steps: |
| 94 | + - uses: actions/download-artifact@v4 |
| 95 | + with: |
| 96 | + pattern: layers-* |
| 97 | + path: dist |
| 98 | + merge-multiple: true |
| 99 | + - name: Checksums and release notes |
| 100 | + working-directory: dist |
| 101 | + run: | |
| 102 | + sha256sum *.zip > SHA256SUMS |
| 103 | + { |
| 104 | + echo "| File | Profile | Python | Arch | OpenCV | NumPy | Unzipped (MB) | Zipped (MB) |" |
| 105 | + echo "|---|---|---|---|---|---|---|---|" |
| 106 | + jq -rs 'sort_by(.file)[] | "| \(.file) | \(.profile) | \(.python) | \(.arch) | \(.opencv) | \(.numpy) | \(.unzipped_mb) | \(.zipped_mb) |"' *.json |
| 107 | + } > ../notes.md |
| 108 | + - uses: softprops/action-gh-release@v2 |
| 109 | + with: |
| 110 | + files: | |
| 111 | + dist/*.zip |
| 112 | + dist/SHA256SUMS |
| 113 | + body_path: notes.md |
0 commit comments