Issue #35: Build on all pushes. #1
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 | |
| on: | |
| push: | |
| branches: ["*"] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [master, main] | |
| jobs: | |
| # ========================================================================= | |
| # C++ tests (quick feedback, no wheel building) | |
| # ========================================================================= | |
| test-cpp: | |
| name: C++ Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache CMake FetchContent | |
| uses: actions/cache@v4 | |
| with: | |
| path: build/_deps | |
| key: deps-${{ matrix.os }}-${{ hashFiles('CMakeLists.txt') }} | |
| restore-keys: | | |
| deps-${{ matrix.os }}- | |
| - name: Configure | |
| run: cmake -B build -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release | |
| - name: Build | |
| run: cmake --build build --config Release --parallel | |
| - name: Test | |
| run: ctest --test-dir build --build-config Release --output-on-failure | |
| # ========================================================================= | |
| # Build wheels for all platforms (Python 3.9-3.13) | |
| # ========================================================================= | |
| build-wheels: | |
| name: Wheels (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-13, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pypa/cibuildwheel@v2.21 | |
| env: | |
| CIBW_BUILD_VERBOSITY: 1 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: wheelhouse/*.whl | |
| # ========================================================================= | |
| # Build source distribution | |
| # ========================================================================= | |
| build-sdist: | |
| name: Source Distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build sdist | |
| run: pipx run build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| # ========================================================================= | |
| # Publish to PyPI on tagged release | |
| # ========================================================================= | |
| publish: | |
| name: Publish to PyPI | |
| needs: [test-cpp, build-wheels, build-sdist] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| environment: pypi | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist | |
| - uses: pypa/gh-action-pypi-publish@release/v1 |