workflow #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test Wheels | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - update | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' # cibuildwheel will use its own Python versions | |
| - name: Install cibuildwheel | |
| run: python -m pip install cibuildwheel | |
| - name: Build wheels | |
| run: python -m cibuildwheel --output-dir wheelhouse | |
| env: | |
| CIBW_BUILD_VERBOSITY: 1 | |
| CIBW_SKIP: "cp37-* cp38-* pp*" # Skip Python 3.7, 3.8 and PyPy as per existing workflows | |
| CIBW_ARCHS_MACOS: "x86_64 arm64" # Build for both architectures on macOS | |
| CIBW_BEFORE_TEST: > | |
| pip install -r {project}/requirements.txt -r {project}/requirements-dev.txt | |
| CIBW_TEST_COMMAND: > | |
| curl -L -o /tmp/test_image.jpg "https://unsplash.com/photos/zQLd8RXbenw/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MzY0MDA3NTd8&force=true&w=2400" && | |
| python {project}/tests/test_all.py --image /tmp/test_image.jpg --quality 1 --method pillow --tonal-spot && | |
| python {project}/tests/test_all.py --image /tmp/test_image.jpg --quality 1 --method cpp --tonal-spot | |
| CIBW_BEFORE_BUILD: > | |
| pip install setuptools wheel | |
| CIBW_ENVIRONMENT: > | |
| PURE_PYTHON=False | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibuildwheel-wheels-${{ matrix.os }} | |
| path: wheelhouse/*.whl | |
| deploy: | |
| name: Publish to PyPI | |
| needs: build_wheels | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| packages_dir: dist |