Skip to content

CMOR Wheel Build

CMOR Wheel Build #56

Workflow file for this run

name: CMOR Wheel Build
run-name: CMOR Wheel Build
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
release:
types: [published]
permissions:
contents: read
jobs:
wheels:
name: Build wheels
strategy:
fail-fast: false
matrix:
runner:
- RUNNER_OS: "ubuntu-24.04"
CIBW_ARCHS: "x86_64"
MACOSX_DEPLOYMENT_TARGET: ""
- RUNNER_OS: "macos-14"
CIBW_ARCHS: "arm64"
MACOSX_DEPLOYMENT_TARGET: "11.0"
- RUNNER_OS: "macos-15-intel"
CIBW_ARCHS: "x86_64"
MACOSX_DEPLOYMENT_TARGET: "11.0"
runs-on: ${{ matrix.runner.RUNNER_OS }}
env:
CIBW_ARCHS: ${{ matrix.runner.CIBW_ARCHS }}
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*"
CIBW_SKIP: "*-musllinux*"
CIBW_BEFORE_ALL: "bash {project}/ci-support/cibw-before-all.sh"
CIBW_BEFORE_BUILD: "bash {project}/ci-support/cibw-before-build.sh"
CIBW_ENVIRONMENT_PASS_LINUX: "CMOR_PYTHON_PACKAGE_VERSION"
CIBW_ENVIRONMENT_LINUX: >-
CMOR_DEPS_PREFIX=/tmp/cmor-deps
CMOR_UDUNITS2_XML=/tmp/cmor-deps/share/cmor/udunits2.xml
NETCDF_C_VERSION=4.10.0
CIBW_ENVIRONMENT_MACOS: >-
CMOR_DEPS_PREFIX=/tmp/cmor-miniforge
CMOR_UDUNITS2_XML=/tmp/cmor-miniforge/share/cmor/udunits2.xml
MACOSX_DEPLOYMENT_TARGET=${{ matrix.runner.MACOSX_DEPLOYMENT_TARGET }}
LDFLAGS='-Wl,-headerpad_max_install_names'
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >-
LD_LIBRARY_PATH=$CMOR_DEPS_PREFIX/lib auditwheel repair --plat manylinux_2_28_x86_64 -w {dest_dir} {wheel}
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >-
DYLD_FALLBACK_LIBRARY_PATH=$CMOR_DEPS_PREFIX/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
CIBW_TEST_REQUIRES: "numpy typing-extensions netcdf4 pyfive hdf5plugin"
CIBW_TEST_COMMAND: "CMOR_WHEEL_ALREADY_INSTALLED=1 CMOR_TEST_DEPS_ALREADY_INSTALLED=1 bash {project}/ci-support/test-wheel.sh"
WHEEL_DIR: ${{ github.workspace }}/wheelhouse
steps:
- name: Checkout branch
if: ${{ github.event_name != 'release' }}
uses: actions/checkout@v4
- name: Checkout release tag
if: ${{ github.event_name == 'release' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Pull Submodules
run: |
git submodule init
git submodule update
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set Python package version
run: |
package_version=$(sed -n "s/^AC_INIT(\\[cmor\\],\\[\\([^]]*\\)\\].*/\\1/p" configure.ac)
if [ -z "$package_version" ]; then
echo "Could not determine package version from configure.ac" >&2
exit 1
fi
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [ "${GITHUB_REF}" = "refs/heads/main" ]; then
python_package_version="${package_version}+${GITHUB_SHA}"
else
python_package_version="${package_version}"
fi
echo "CMOR_PYTHON_PACKAGE_VERSION=${python_package_version}" >> "$GITHUB_ENV"
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel
- name: Build and test wheels
run: |
python -m cibuildwheel --output-dir wheelhouse
- name: Upload wheels as workflow artifacts
if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
uses: actions/upload-artifact@v4
with:
name: wheelhouse-${{ matrix.runner.RUNNER_OS }}-${{ matrix.runner.CIBW_ARCHS }}
path: wheelhouse/*.whl
if-no-files-found: error
retention-days: 1
publish_release:
name: Publish wheels
if: ${{ github.event_name == 'release' }}
needs: wheels
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheelhouse-*
merge-multiple: true
path: wheelhouse
- name: Upload wheels to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name }}
files: wheelhouse/*.whl
fail_on_unmatched_files: true
build_pages_index:
name: Build Pages wheel index
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: wheels
runs-on: ubuntu-24.04
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheelhouse-*
merge-multiple: true
path: wheelhouse
- name: Build Pages site
run: |
bash ci-support/build-wheel-pages-index.sh wheelhouse site
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
deploy_pages:
name: Deploy wheel index
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: build_pages_index
runs-on: ubuntu-24.04
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4