|
| 1 | +name: Build PYPI wheels for opencv-python on Macos M1 |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths-ignore: |
| 8 | + - '.github/workflows/build_wheels_linux*' |
| 9 | + - '.github/workflows/build_wheels_windows*' |
| 10 | + - '.github/workflows/build_wheels_macos.yml' |
| 11 | + release: |
| 12 | + types: [published, edited] |
| 13 | + |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + os: [macOS-M1] |
| 23 | + python-version: [3.7, 3.8, 3.9] |
| 24 | + platform: [x64] |
| 25 | + with_contrib: [0, 1] |
| 26 | + without_gui: [0, 1] |
| 27 | + build_sdist: [0] |
| 28 | + |
| 29 | + env: |
| 30 | + SDIST: ${{ matrix.build_sdist || 0 }} |
| 31 | + ENABLE_HEADLESS: ${{ matrix.without_gui }} |
| 32 | + ENABLE_CONTRIB: ${{ matrix.with_contrib }} |
| 33 | + OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v2 |
| 38 | + with: |
| 39 | + submodules: false |
| 40 | + fetch-depth: 0 |
| 41 | + |
| 42 | + - name: Update submodules |
| 43 | + if: github.event_name == 'pull_request' |
| 44 | + run: git submodule update --remote |
| 45 | + |
| 46 | + - name: build script |
| 47 | + run: | |
| 48 | + git submodule update --init multibuild |
| 49 | + echo $ENABLE_CONTRIB > contrib.enabled |
| 50 | + echo $ENABLE_HEADLESS > headless.enabled |
| 51 | + export MACOSX_DEPLOYMENT_TARGET=11.0 |
| 52 | + arch -arm64 python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose |
| 53 | + - name: before test |
| 54 | + run: | |
| 55 | + git submodule update --init --recursive |
| 56 | + arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl |
| 57 | + cd ${{ github.workspace }}/tests |
| 58 | + arch -arm64 python${{ matrix.python-version }} get_build_info.py |
| 59 | + - name: run test |
| 60 | + run: | |
| 61 | + cd ${{ github.workspace }}/opencv |
| 62 | + arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo . |
| 63 | + - name: saving artifacts |
| 64 | + uses: actions/upload-artifact@v2 |
| 65 | + with: |
| 66 | + name: wheels |
| 67 | + path: wheelhouse/opencv*.whl |
| 68 | + |
| 69 | + test_release_opencv_python: |
| 70 | + if: github.event_name == 'release' && github.event.release.prerelease |
| 71 | + needs: [build] |
| 72 | + runs-on: ubuntu-latest |
| 73 | + environment: test-opencv-python-release |
| 74 | + defaults: |
| 75 | + run: |
| 76 | + shell: bash |
| 77 | + steps: |
| 78 | + - uses: actions/download-artifact@v2 |
| 79 | + with: |
| 80 | + name: wheels |
| 81 | + path: wheelhouse/ |
| 82 | + |
| 83 | + - name: Upload all wheels |
| 84 | + run: | |
| 85 | + python -m pip install twine |
| 86 | + python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_* |
| 87 | +
|
| 88 | + release_opencv_python: |
| 89 | + if: github.event_name == 'release' && !github.event.release.prerelease |
| 90 | + needs: [build] |
| 91 | + runs-on: ubuntu-latest |
| 92 | + environment: opencv-python-release |
| 93 | + defaults: |
| 94 | + run: |
| 95 | + shell: bash |
| 96 | + steps: |
| 97 | + - uses: actions/download-artifact@v2 |
| 98 | + with: |
| 99 | + name: wheels |
| 100 | + path: wheelhouse/ |
| 101 | + |
| 102 | + - name: Upload wheels for opencv_python |
| 103 | + run: | |
| 104 | + python -m pip install twine |
| 105 | + python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* |
| 106 | + - name: Upload wheels for opencv_contrib_python |
| 107 | + run: | |
| 108 | + python -m pip install twine |
| 109 | + python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* |
| 110 | + - name: Upload wheels for opencv_python_headless |
| 111 | + run: | |
| 112 | + python -m pip install twine |
| 113 | + python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* |
| 114 | + - name: Upload wheels for opencv_contrib_python_headless |
| 115 | + run: | |
| 116 | + python -m pip install twine |
| 117 | + python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-* |
0 commit comments