|
| 1 | +name: Wheels |
| 2 | + |
| 3 | +on: [ push, pull_request ] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build_wheels: |
| 7 | + name: Build wheels on ${{ matrix.os }} |
| 8 | + if: ${{ startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[pypi]') }} |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: [ macos-11, macos-12, macos-13, flyci-macos-large-latest-m2, macos-14, ubuntu-latest, windows-latest ] |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: awvwgk/setup-fortran@main |
| 16 | + if: matrix.os == 'windows-latest' |
| 17 | + id: setup-fortran |
| 18 | + with: |
| 19 | + compiler: gcc |
| 20 | + version: 11 |
| 21 | + |
| 22 | + - run: ln -s $(which gfortran-11) /usr/local/bin/gfortran |
| 23 | + if: matrix.os != 'windows-latest' |
| 24 | + |
| 25 | + - run: gfortran --version |
| 26 | + |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + submodules: recursive |
| 30 | + |
| 31 | + - uses: actions/setup-python@v5 |
| 32 | + |
| 33 | + - name: Install cibuildwheel |
| 34 | + run: python -m pip install cibuildwheel==2.18.1 |
| 35 | + |
| 36 | + - name: Build macos-13 wheels |
| 37 | + if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' || matrix.os == 'flyci-macos-large-latest-m2' |
| 38 | + env: |
| 39 | + MACOSX_DEPLOYMENT_TARGET: 13 |
| 40 | + CIBW_BUILD: cp311-* |
| 41 | + CIBW_SKIP: pp* |
| 42 | + CIBW_BUILD_VERBOSITY: 1 |
| 43 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 44 | + |
| 45 | + - name: Build macos-12 wheels |
| 46 | + if: matrix.os == 'macos-12' |
| 47 | + env: |
| 48 | + MACOSX_DEPLOYMENT_TARGET: 12 |
| 49 | + CIBW_BUILD: cp311-* |
| 50 | + CIBW_SKIP: pp* |
| 51 | + CIBW_BUILD_VERBOSITY: 1 |
| 52 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 53 | + |
| 54 | + - name: Build macos-11 wheels |
| 55 | + if: matrix.os == 'macos-11' |
| 56 | + env: |
| 57 | + # all cp3xx, since old macs seem to only use osx 11+ builds if this is set not "none" |
| 58 | + # see consistency with get_tag() in setup.py |
| 59 | + MACOSX_DEPLOYMENT_TARGET: 11 |
| 60 | + CIBW_SKIP: pp* |
| 61 | + CIBW_BUILD_VERBOSITY: 1 |
| 62 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 63 | + |
| 64 | + - name: Build wheels |
| 65 | + if: matrix.os == 'macos-14' || matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest' |
| 66 | + env: |
| 67 | + MACOSX_DEPLOYMENT_TARGET: 14 |
| 68 | + CIBW_BUILD: cp311-* |
| 69 | + CIBW_SKIP: pp* *-win32 *-manylinux_i686 *musllinux* |
| 70 | + CIBW_BUILD_VERBOSITY: 1 |
| 71 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 72 | + |
| 73 | + - uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: wheels-${{ matrix.os }} |
| 76 | + path: | |
| 77 | + wheelhouse/*.whl |
| 78 | +
|
| 79 | + build-sdist-and-upload: |
| 80 | + runs-on: ubuntu-latest |
| 81 | + needs: [ 'build_wheels' ] |
| 82 | + environment: wheels |
| 83 | + if: github.repository_owner == 'cmbant' |
| 84 | + permissions: |
| 85 | + id-token: write |
| 86 | + |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + with: |
| 90 | + submodules: recursive |
| 91 | + |
| 92 | + - name: Set up Python |
| 93 | + uses: actions/setup-python@v5 |
| 94 | + with: |
| 95 | + python-version: "3.10" |
| 96 | + cache: pip |
| 97 | + cache-dependency-path: "setup.py" |
| 98 | + |
| 99 | + - name: Install dependencies |
| 100 | + run: | |
| 101 | + python -m pip install -U pip |
| 102 | + python -m pip install -U build twine |
| 103 | +
|
| 104 | + - name: Download wheels from build artifacts |
| 105 | + uses: actions/download-artifact@v4 |
| 106 | + with: |
| 107 | + pattern: wheels-* |
| 108 | + merge-multiple: true |
| 109 | + path: dist-wheels/ |
| 110 | + |
| 111 | + - name: Build package |
| 112 | + run: | |
| 113 | + python -m build --sdist |
| 114 | + twine check --strict dist/* |
| 115 | + twine check --strict dist-wheels/* |
| 116 | +
|
| 117 | + - name: Publish wheels to PyPI Test |
| 118 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 119 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 120 | + with: |
| 121 | + repository-url: https://test.pypi.org/legacy/ |
| 122 | + packages-dir: dist-wheels/ |
| 123 | + |
| 124 | + - name: Publish sdist to PyPI Test |
| 125 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 126 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 127 | + with: |
| 128 | + repository-url: https://test.pypi.org/legacy/ |
| 129 | + |
| 130 | + - name: Publish wheels to PyPI |
| 131 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 132 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 133 | + with: |
| 134 | + packages-dir: dist-wheels/ |
| 135 | + |
| 136 | + - name: Publish sdist to PyPI |
| 137 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 138 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 139 | + |
| 140 | + test_wheels: |
| 141 | + name: Test wheels on ${{ matrix.os }} |
| 142 | + if: contains(github.event.head_commit.message, '[testpypi]') |
| 143 | + runs-on: ${{ matrix.os }} |
| 144 | + strategy: |
| 145 | + matrix: |
| 146 | + os: [ macos-11, macos-12, macos-13, flyci-macos-large-latest-m2, macos-14, ubuntu-latest, windows-latest ] |
| 147 | + |
| 148 | + steps: |
| 149 | + - uses: actions/setup-python@v5 |
| 150 | + |
| 151 | + - name: install |
| 152 | + run: python -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ camb |
| 153 | + |
| 154 | + - name: test |
| 155 | + run: python -m unittest camb.tests.camb_test |
0 commit comments