Skip to content
name: Publish sdist and wheels for macos, and manylinux, publish to pypi if a release
on: [pull_request, push]
env:
apt_options: -o Acquire::Retries=3
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: 'cp*'
CIBW_SKIP: 'cp35-* cp36-* cp37-* cp38-* *-musllinux_* *-manylinux_i686'
CIBW_TEST_COMMAND: ( cd {project}/python/tests; python -m unittest -v )
UNIXY_HDF5_VERSION: 1.14.3
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-20.04, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel
- name: Cache HDF5 On Linux/macOS
if: runner.os == 'Linux' || runner.os == 'macOS'
uses: actions/cache@v3
id: cache-hdf5-posix
env:
cache-name: cache-hdf5-posix
with:
path: src-cache/
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Build wheels on Linux
if: runner.os == 'Linux'
env:
CIBW_ENVIRONMENT_PASS: "STATIC_HDF5 CMAKE_PREFIX_PATH"
CIBW_BEFORE_BUILD: |
# CMake complains if the dependencies come from within the same tree
# as the source, so we'll just pretend they are elsewhere
mkdir -p /host/home/runner/work/src-cache
ln -s /host/home/runner/work/src-cache /opt/hdf5-static
bash ci/hdf5-build.sh /opt/hdf5-static
run: |
# used by setup.py to decide if to set `FindHDF5` to use static hdf5 libraries
export STATIC_HDF5=True
export CMAKE_PREFIX_PATH=/opt/hdf5-static/install-x86_64/install/
CIBW_MANYLINUX_X86_64_IMAGE=manylinux2014 python -m cibuildwheel --output-dir dist
CIBW_MANYLINUX_X86_64_IMAGE=manylinux_2_28 python -m cibuildwheel --output-dir dist
- name: Build wheels Mac OS
if: runner.os == 'macOS'
env:
CIBW_ENVIRONMENT_PASS: "STATIC_HDF5 CMAKE_PREFIX_PATH"
CIBW_BEFORE_BUILD: |
# CMake complains if the dependencies come from within the same tree
# as the source, so we'll just pretend they are elsewhere
mkdir -p $PWD/src-cache
ln -s $PWD/src-cache /Users/runner/work/src-cache
bash ci/hdf5-build.sh /Users/runner/work/src-cache
run: |
# used by setup.py to decide if to set `FindHDF5` to use static hdf5 libraries
export STATIC_HDF5=True
export CMAKE_PREFIX_PATH=/Users/runner/work/src-cache/install-`uname -m`/install
python -m cibuildwheel --output-dir dist
- name: Store wheel as artifact
uses: actions/upload-artifact@v4
with:
name: dist-wheels-${{ matrix.os }}
path: dist/*.whl
build_sdist:
name: Build sdist
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install packages
run: |
sudo apt-get ${{env.apt_options}} update -y
sudo apt-get ${{env.apt_options}} install -y libhdf5-dev
- name: Build a source tarball, check it installs
run:
./ci/python_build_sdist.sh
- name: Store sdist as artifact
uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*.tar.gz
upload_artifacts:
name: Upload wheels to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
steps:
- name: Download artifacts produced during the build_wheels and build_sdist jobs
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist/
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R
working-directory: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: dist/