|
| 1 | +name: Build and deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + release: |
| 6 | + types: |
| 7 | + - published |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_sdist: |
| 11 | + name: Build source distribution |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + - uses: actions/setup-python@v4 |
| 16 | + with: |
| 17 | + python-version: '3.11' |
| 18 | + cache: 'pip' |
| 19 | + - name: Install dependencies |
| 20 | + run: | |
| 21 | + python -m pip install --upgrade pip |
| 22 | + pip install build twine |
| 23 | + - name: Build sdist |
| 24 | + run: python -m build --sdist |
| 25 | + - name: Check the package |
| 26 | + run: | |
| 27 | + python -m twine check dist/* |
| 28 | + - uses: actions/upload-artifact@v3 |
| 29 | + with: |
| 30 | + path: dist/*.tar.gz |
| 31 | + |
| 32 | + test_sdist: |
| 33 | + needs: [build_sdist] |
| 34 | + name: Test source distribution |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - uses: actions/setup-python@v4 |
| 39 | + with: |
| 40 | + python-version: '3.11' |
| 41 | + cache: 'pip' |
| 42 | + - uses: actions/download-artifact@v3 |
| 43 | + with: |
| 44 | + name: artifact |
| 45 | + path: dist |
| 46 | + - name: Install sdist |
| 47 | + run: pip install --pre dist/hdf5plugin*.tar.gz |
| 48 | + - name: Run tests |
| 49 | + run: python test/test.py |
| 50 | + |
| 51 | + build_wheels: |
| 52 | + name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }} |
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + strategy: |
| 55 | + # Ensure that a wheel builder finishes even if another fails |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + include: |
| 59 | + - os: ubuntu-20.04 |
| 60 | + cibw_archs: "auto64" |
| 61 | + with_sse2: true |
| 62 | + - os: ubuntu-20.04 |
| 63 | + cibw_archs: "aarch64" |
| 64 | + with_sse2: false |
| 65 | + - os: ubuntu-20.04 |
| 66 | + cibw_archs: "ppc64le" |
| 67 | + with_sse2: false |
| 68 | + - os: windows-2019 |
| 69 | + cibw_archs: "auto64" |
| 70 | + with_sse2: true |
| 71 | + - os: macos-11 |
| 72 | + cibw_archs: "universal2" |
| 73 | + with_sse2: true |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + - uses: docker/setup-qemu-action@v3 |
| 78 | + if: runner.os == 'Linux' |
| 79 | + with: |
| 80 | + platforms: all |
| 81 | + - uses: pypa/cibuildwheel@v2.16.2 |
| 82 | + env: |
| 83 | + # Configure hdf5plugin build |
| 84 | + HDF5PLUGIN_OPENMP: "False" |
| 85 | + HDF5PLUGIN_NATIVE: "False" |
| 86 | + HDF5PLUGIN_SSE2: ${{ matrix.with_sse2 && 'True' || 'False' }} |
| 87 | + HDF5PLUGIN_AVX2: "False" |
| 88 | + HDF5PLUGIN_AVX512: "False" |
| 89 | + HDF5PLUGIN_BMI2: "False" |
| 90 | + HDF5PLUGIN_CPP11: "True" |
| 91 | + HDF5PLUGIN_CPP14: "True" |
| 92 | + |
| 93 | + CIBW_ENVIRONMENT_PASS_LINUX: HDF5PLUGIN_OPENMP HDF5PLUGIN_NATIVE HDF5PLUGIN_SSE2 HDF5PLUGIN_AVX2 HDF5PLUGIN_AVX512 HDF5PLUGIN_BMI2 HDF5PLUGIN_CPP11 HDF5PLUGIN_CPP14 |
| 94 | + |
| 95 | + # Use Python3.11 to build wheels that are compatible with all supported version of Python |
| 96 | + CIBW_BUILD: cp311-* |
| 97 | + # Do not build for pypy and muslinux |
| 98 | + CIBW_SKIP: pp* *-musllinux_* |
| 99 | + CIBW_ARCHS: ${{ matrix.cibw_archs }} |
| 100 | + |
| 101 | + # Use silx wheelhouse for ppc64le |
| 102 | + CIBW_BEFORE_TEST: pip install h5py --only-binary ":all:" --find-links=https://www.silx.org/pub/wheelhouse/ --trusted-host=www.silx.org |
| 103 | + CIBW_TEST_COMMAND: python {project}/test/test.py |
| 104 | + - uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + path: ./wheelhouse/*.whl |
| 107 | + |
| 108 | + test_wheels: |
| 109 | + needs: [build_wheels] |
| 110 | + name: Test wheel on ${{ matrix.os }}-${{ matrix.python-version }} |
| 111 | + runs-on: ${{ matrix.os }} |
| 112 | + strategy: |
| 113 | + matrix: |
| 114 | + os: [ubuntu-latest, windows-2019, macos-11] |
| 115 | + python-version: ['3.7', '3.12'] |
| 116 | + include: |
| 117 | + - python-version: '3.7' |
| 118 | + OLDEST_DEPENDENCIES: 'h5py==2.8.0' |
| 119 | + - python-version: '3.12' |
| 120 | + OLDEST_DEPENDENCIES: 'h5py==3.10.0' |
| 121 | + |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
| 124 | + - uses: actions/setup-python@v4 |
| 125 | + with: |
| 126 | + python-version: ${{ matrix.python-version }} |
| 127 | + cache: 'pip' |
| 128 | + - uses: actions/download-artifact@v3 |
| 129 | + with: |
| 130 | + name: artifact |
| 131 | + path: dist |
| 132 | + - name: Install h5py and hdf5plugin |
| 133 | + run: | |
| 134 | + pip install h5py |
| 135 | + pip install --no-index --no-cache --find-links=./dist hdf5plugin --only-binary hdf5plugin |
| 136 | + - name: Run test with latest h5py |
| 137 | + run: python test/test.py |
| 138 | + - name: Run test with oldest h5py |
| 139 | + run: | |
| 140 | + pip install ${{ matrix.OLDEST_DEPENDENCIES }} |
| 141 | + python test/test.py |
| 142 | +
|
| 143 | + pypi-publish: |
| 144 | + needs: [build_wheels, build_sdist, test_wheels, test_sdist] |
| 145 | + name: Upload release to PyPI |
| 146 | + runs-on: ubuntu-latest |
| 147 | + environment: |
| 148 | + name: pypi |
| 149 | + permissions: |
| 150 | + id-token: write |
| 151 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 152 | + # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) |
| 153 | + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 154 | + steps: |
| 155 | + - uses: actions/download-artifact@v3 |
| 156 | + with: |
| 157 | + name: artifact |
| 158 | + path: dist |
| 159 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments