|
| 1 | +name: Release to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + BuildWheel: |
| 9 | + name: BuildWheel-${{ matrix.os }} |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-14, macos-15-intel] |
| 15 | + # os: [ubuntu-latest] |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + shell: bash -l {0} |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + # When re-running a PR job, GitHub Actions uses the merge commit created at |
| 26 | + # the time of the original run, not a fresh merge with the latest target branch. |
| 27 | + # This step ensures we always test against the most recent target branch. |
| 28 | + - name: Merge with latest target branch (pull_request only) |
| 29 | + if: github.event_name == 'pull_request' |
| 30 | + run: | |
| 31 | + git fetch origin ${{ github.event.pull_request.base.ref }} |
| 32 | + git merge --no-edit origin/${{ github.event.pull_request.base.ref }} |
| 33 | +
|
| 34 | + - name: Cache Ccache Directory (pull_request) |
| 35 | + if: ${{ github.event_name == 'pull_request' }} |
| 36 | + uses: actions/cache@v4 |
| 37 | + with: |
| 38 | + path: | |
| 39 | + ~/.ccache |
| 40 | + key: ccache-${{ runner.os }}-${{ github.event.pull_request.head.ref }}-${{ github.sha }} |
| 41 | + restore-keys: | |
| 42 | + ccache-${{ runner.os }}-${{ github.event.pull_request.head.ref }}- |
| 43 | + ccache-${{ runner.os }}-${{ github.event.pull_request.base.ref }}- |
| 44 | +
|
| 45 | + - name: Set Ccache Directory |
| 46 | + run: | |
| 47 | + echo "Start building---------------------------------" |
| 48 | + export CCACHE_DIR="${HOME}/.ccache" |
| 49 | +
|
| 50 | + - name: Setup macOS |
| 51 | + if: matrix.os == 'macos-15-intel' || matrix.os == 'macos-14' |
| 52 | + run: | |
| 53 | + if [[ ${{ matrix.os }} == 'macos-15-intel' ]]; then |
| 54 | + echo "MACOSX_DEPLOYMENT_TARGET=15.0" >> "$GITHUB_ENV" |
| 55 | + elif [[ ${{ matrix.os }} == 'macos-14' ]]; then |
| 56 | + echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> "$GITHUB_ENV" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Build Wheels |
| 60 | + uses: pypa/cibuildwheel@v3.3.0 |
| 61 | + env: |
| 62 | + CMAKE_C_COMPILER_LAUNCHER: ccache |
| 63 | + CMAKE_CXX_COMPILER_LAUNCHER: ccache |
| 64 | + CMAKE_CUDA_COMPILER_LAUNCHER: ccache |
| 65 | + # DO NOT enable this line because the script for conda build is not |
| 66 | + # executed in a interactive shell, and "~" will not be expanded to the |
| 67 | + # home directory. Export CCACHE_DIR in the run command instead. |
| 68 | + # CCACHE_DIR: ~/.ccache |
| 69 | + CCACHE_MAXSIZE: 1G # The limit of actions/cache is 10GB |
| 70 | + # Pass environment variables into cibuildwheel build environments |
| 71 | + # This is only needed on Linux becuase the wheels are built in docker |
| 72 | + # images only on Linux. |
| 73 | + CIBW_ENVIRONMENT_PASS_LINUX: CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER CMAKE_CUDA_COMPILER_LAUNCHER CCACHE_MAXSIZE |
| 74 | + |
| 75 | + - uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 78 | + path: ./wheelhouse/*.whl |
0 commit comments