Issue #33: New push cancels old runs. #3
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] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| 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 -DBUILD_PYTHON_BINDINGS=OFF -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) | |
| # Only runs after C++ tests pass. | |
| # ========================================================================= | |
| build-wheels: | |
| name: Wheels (${{ matrix.os }}) | |
| needs: [test-cpp] | |
| 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: 3 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: wheelhouse/*.whl | |
| # ========================================================================= | |
| # Publish to PyPI on tagged release | |
| # ========================================================================= | |
| publish: | |
| name: Publish to PyPI | |
| needs: [test-cpp, build-wheels] | |
| 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: pypa/gh-action-pypi-publish@release/v1 |