diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 56d1505a..8d3b132f 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -8,11 +8,80 @@ on: branches: - master release: - # Only use the types keyword to narrow down the activity types that will trigger your workflow. - types: [published, created, edited] + types: [published, edited] jobs: + build-windows-x86_64: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: powershell + + strategy: + fail-fast: false + matrix: + os: [windows-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + platform: [x86, x64] + with_contrib: [0, 1] + without_gui: [0, 1] + build_sdist: [0] + + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + SDIST: ${{ matrix.build_sdist || 0}} + ENABLE_HEADLESS: ${{ matrix.without_gui }} + ENABLE_CONTRIB: ${{ matrix.with_contrib }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + + - name: Update submodules + run: | + git submodule update --remote + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.platform }} + + - name: Setup MSBuild.exe + uses: warrenbuckley/Setup-MSBuild@v1 + + - name: build script + run: | + python --version + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools + set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose + shell: cmd + + - name: before test + run: | + cd ${{ github.workspace }}/tests + $env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command" + &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl") + if ($LastExitCode -ne 0) {throw $LastExitCode} + shell: powershell + + - name: run test + run: | + cd ${{ github.workspace }}/tests + python -m unittest test + shell: cmd + + - name: saving artifacts + uses: actions/upload-artifact@v2 + with: + name: wheels + path: wheelhouse/opencv*.whl + build: runs-on: ${{ matrix.os }} defaults: @@ -22,17 +91,12 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest] python-version: [3.6, 3.7, 3.8, 3.9] - platform: [x32, x64] + platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - exclude: - - os: macos-latest - platform: x32 - - os: ubuntu-latest - platform: x32 env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true @@ -68,9 +132,9 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.platform }} - name: Setup Environment variables - if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} run: | if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi @@ -79,7 +143,6 @@ jobs: echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; - name: before install - if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} run: | set -e if [[ $SDIST == 0 ]]; then @@ -123,89 +186,31 @@ jobs: #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817 trap ERR test "$rc" -eq 0 - - - name: Setup MSBuild.exe - if: ${{ matrix.os == 'windows-latest' }} - uses: warrenbuckley/Setup-MSBuild@v1 - - - name: build script - if: ${{ matrix.os == 'windows-latest' }} - run: | - python --version - python -m pip install --upgrade pip - python -m pip install --upgrade setuptools - set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\dist . --verbose - shell: cmd - - - name: before test - if: ${{ matrix.os == 'windows-latest' }} - run: | - cd ${{ github.workspace }}/tests - $env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command" - &python -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl") - if ($LastExitCode -ne 0) {throw $LastExitCode} - shell: powershell - - - name: run test - if: ${{ matrix.os == 'windows-latest' }} - run: | - cd ${{ github.workspace }}/tests - python -m unittest test - shell: cmd - - name: saving artifacts - if: ${{ matrix.os == 'windows-latest' }} uses: actions/upload-artifact@v2 with: - name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }} - path: dist\opencv*.whl + name: wheels + path: wheelhouse/opencv*.whl - - name: saving artifacts - if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }} - path: ./wheelhouse/opencv*.whl - - - # - name: Upload wheels ${{ matrix.os }} - # if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} - # env: - # # PYPI repository - # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - # # PYPITEST repository - # # TWINE_USERNAME: ${{ secrets.PYPITEST_USERNAME }} - # # TWINE_PASSWORD: ${{ secrets.PYPITEST_PASSWORD }} - # # TWINE_REPOSITORY_URL: 'https://test.pypi.org/legacy/' - # run: | - # twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/* - # # Upload wheels to PYPITEST - # #twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/* - - # - name: Upload wheels ${{ matrix.os }} - # if: ${{ matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')}} - # env: - # USER: fXgF9uyy6sT0JoVOR7BoqA== - # PASS: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys= - # run: | - # cd ${{ github.workspace }} - # if (${Env:ENABLE_CONTRIB} -eq 0) { - # if (${Env:ENABLE_HEADLESS} -eq 0) { - # echo "This is a default build. Deployment will be done to PyPI entry opencv-python." - # } - # else { - # echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless." - # } - # } - # else { - # if (${Env:ENABLE_HEADLESS} -eq 0) { - # echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python." - # } - # else { - # echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless." - # } - # } - # &python -m pip install twine - # &python -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv* - # shell: powershell + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: [build, build-windows-x86_64] + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/download-artifact@v2 + with: + name: wheels + path: wheelhouse/ + + - name: Upload wheels ${{ matrix.os }} + if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} && startsWith(github.ref, 'refs/tags/') + env: + # PYPI repository credentials + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m pip install twine + python -m twine upload -u ${Env:TWINE_USERNAME} -p ${Env:TWINE_PASSWORD} --skip-existing wheelhouse/opencv*