Refactor CI workflow to support manylinux wheels #81
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: samplerate | |
| on: [push, pull_request] | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: [3.9, "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Build package | |
| run: | | |
| python -m pip install -e . | |
| - name: Test with pytest | |
| run: | | |
| pytest | |
| build_sdist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Build sdist | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -U setuptools setuptools_scm build twine | |
| python -m build --sdist | |
| twine check dist/* | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| build_wheels: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| if: runner.os == 'Linux' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| - uses: pypa/cibuildwheel@v3.4.0 | |
| env: | |
| CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*" | |
| CIBW_ARCHS_LINUX: "x86_64 aarch64" | |
| CIBW_ARCHS_WINDOWS: "AMD64" | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
| CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 | |
| CIBW_TEST_REQUIRES: "pytest numpy" | |
| CIBW_TEST_COMMAND: "pytest {project}/tests" | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: wheelhouse/*.whl | |
| publish: | |
| needs: [test, build_sdist, build_wheels] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Validate wheels | |
| run: | | |
| pip install twine | |
| twine check dist/* | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
| TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
| run: | | |
| twine upload --skip-existing dist/* | |
| publish-test: | |
| needs: [test, build_sdist, build_wheels] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/test-') | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Validate wheels | |
| run: | | |
| pip install twine | |
| twine check dist/* | |
| - name: Publish to PyPI Test | |
| env: | |
| TWINE_USERNAME: ${{ secrets.PYPITEST_USERNAME }} | |
| TWINE_PASSWORD: ${{ secrets.PYPITEST_PASSWORD }} | |
| TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ | |
| run: | | |
| twine upload --skip-existing dist/* |