Skip to content

[pre-commit.ci] pre-commit autoupdate #168

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #168

Workflow file for this run

# Copyright (C) 2023 Roberto Rossini (roberros@uio.no)
# SPDX-License-Identifier: MIT
name: Build wheels
on:
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/build-wheels.yml"
- "cmake/**"
- "src/**"
- "test/*.py"
- "utils/devel/stubgen.py"
- "CMakeLists.txt"
- "conanfile.py"
- "pyproject.toml"
pull_request:
paths:
- ".github/workflows/build-wheels.yml"
- "cmake/**"
- "src/**"
- "test/*.py"
- "utils/devel/stubgen.py"
- "CMakeLists.txt"
- "conanfile.py"
- "pyproject.toml"
release:
types:
- published
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
matrix-factory:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-result.outputs.matrix }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install cibuildwheel
run: pip install 'cibuildwheel>=2.21'
- name: Generate matrix
id: set-result
run: |
CIBW_ARCHS_LINUX=x86_64 cibuildwheel \
--print-build-identifiers \
--platform linux |
jq -nRc '{"wheel-config": inputs, "os": "ubuntu-24.04", "arch": "x86_64"}' |
tee configs.json
if [ '${{ github.event_name }}' != 'pull_request' ]; then
CIBW_ARCHS_LINUX=aarch64 cibuildwheel \
--print-build-identifiers \
--platform linux |
jq -nRc '{"wheel-config": inputs, "os": "ubuntu-24.04-arm", "arch": "aarch64"}' |
tee -a configs.json
fi
CIBW_ARCHS_MACOS=x86_64 cibuildwheel \
--print-build-identifiers \
--platform macos |
jq -nRc '{"wheel-config": inputs, "os": "macos-15-intel", "arch": "x86_64"}' |
tee -a configs.json
CIBW_ARCHS_MACOS=arm64 cibuildwheel \
--print-build-identifiers \
--platform macos |
jq -nRc '{"wheel-config": inputs, "os": "macos-26", "arch": "arm64"}' |
tee -a configs.json
CIBW_ARCHS_WINDOWS=AMD64 cibuildwheel \
--print-build-identifiers \
--platform windows |
jq -nRc '{"wheel-config": inputs, "os": "windows-2022", "arch": "AMD64"}' |
tee -a configs.json
MATRIX="$(jq -sc < configs.json)"
echo "matrix={\"include\": $MATRIX }" | tee -a "$GITHUB_OUTPUT"
build-deps-linux-x86:
name: Build Conan deps (Linux; x86_64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps-linux.yml@b86ff92565b4b8c27f58427468e6471a23de5de3
with:
os: ubuntu-24.04
arch: x86_64
cppstd: 23
conan-version: "2.21.*"
image-version: 2025.10.19-2
ref: main
build-deps-linux-arm64:
name: Build Conan deps (Linux; arm64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps-linux.yml@b86ff92565b4b8c27f58427468e6471a23de5de3
with:
os: ubuntu-24.04-arm
arch: aarch64
cppstd: 23
conan-version: "2.21.*"
image-version: 2025.10.19-2
ref: main
build-deps-macos-x86:
name: Build Conan deps (macOS; x86_64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps-macos.yml@b86ff92565b4b8c27f58427468e6471a23de5de3
with:
conan-version: "2.21.*"
cppstd: 23
os: macos-15-intel
ref: main
build-deps-macos-arm64:
name: Build Conan deps (macOS; arm64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps-macos.yml@b86ff92565b4b8c27f58427468e6471a23de5de3
with:
conan-version: "2.21.*"
cppstd: 23
os: macos-26
ref: main
build-deps-windows-x86:
name: Build Conan deps (Windows; x86_64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps-windows.yml@b86ff92565b4b8c27f58427468e6471a23de5de3
with:
conan-version: "2.21.*"
cppstd: 23
os: windows-2022
ref: main
# required to support Windows 10 LTSC 2019 (1809)
# EOL: https://learn.microsoft.com/en-us/lifecycle/products/windows-10-enterprise-ltsc-2019
winsdk-version: "10.0.17763.0"
build-sdist:
name: Build SDist
runs-on: ubuntu-latest
env:
CC: "clang"
CXX: "clang++"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
with:
python-version: 3.14
activate-environment: true
enable-cache: true
- name: Build SDist
run: uv build --sdist
- name: Check metadata
run: uvx twine check dist/*
- name: Generate cache key
id: cache-key
run: |
hash="${{ hashFiles('conanfile.py') }}"
echo "conan-key=sdist-$hash" >> "$GITHUB_OUTPUT"
- name: Restore Conan cache
id: cache-conan
uses: actions/cache/restore@v4
with:
key: conan-${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
- name: Clean Conan cache (post build)
if: steps.cache-conan.outputs.cache-hit != 'true'
run: rm -rf '${{ env.CONAN_HOME }}/p'
- name: Test SDist
run: |
uv pip install -v dist/hictkpy*.tar.gz
python -c 'import hictkpy; print(hictkpy.__version__)'
- name: Clean Conan cache (post build)
if: steps.cache-conan.outputs.cache-hit != 'true'
run: |
uv tool run 'conan>2' cache clean "*" --build
uv tool run 'conan>2' cache clean "*" --download
uv tool run 'conan>2' cache clean "*" --source
- name: Save Conan cache
uses: actions/cache/save@v4
if: steps.cache-conan.outputs.cache-hit != 'true'
with:
key: conan-${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
- uses: actions/upload-artifact@v5
with:
name: sdist
path: dist/hictkpy*.tar.gz
build-wheels:
name: Build Wheels
needs:
- matrix-factory
- build-deps-linux-x86
- build-deps-linux-arm64
- build-deps-macos-x86
- build-deps-macos-arm64
- build-deps-windows-x86
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-factory.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Add devtools to PATH (Windows)
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
sdk: ${{ needs.build-deps-windows-x86.outputs.winsdk-version }}
- name: Install uv
if: ${{ !startsWith(matrix.os, 'ubuntu') }}
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: true
- name: Set TMPDIR (UNIX)
if: ${{ !startsWith(matrix.os, 'windows') }}
run: echo 'TMPDIR=/tmp' | tee -a "$GITHUB_ENV"
- name: Set TMPDIR (Windows)
if: startsWith(matrix.os, 'windows')
run: |
cat << EOF >> get_tmpdir.py
import pathlib
import tempfile
path = pathlib.Path(tempfile.gettempdir())
print(path.as_posix())
EOF
echo "TMPDIR=$(python get_tmpdir.py)" | tee -a "$GITHUB_ENV"
- name: Generate cache key
id: cache-key
run: |
set -e
set -u
arch='${{ matrix.arch }}'
os='${{ matrix.os }}'
if [[ "$os" == ubuntu-* && "$arch" == x86_64 ]]; then
deps_cache_key='${{ needs.build-deps-linux-x86.outputs.cache-key }}'
deps_cache_path='${{ needs.build-deps-linux-x86.outputs.tar }}'
elif [[ "$os" == ubuntu-* && "$arch" == aarch64 ]]; then
deps_cache_key='${{ needs.build-deps-linux-arm64.outputs.cache-key }}'
deps_cache_path='${{ needs.build-deps-linux-arm64.outputs.tar }}'
elif [[ "$os" == macos-* && "$arch" == x86_64 ]]; then
deps_cache_key='${{ needs.build-deps-macos-x86.outputs.cache-key }}'
deps_cache_path='${{ needs.build-deps-macos-x86.outputs.tar }}'
elif [[ "$os" == macos-* && "$arch" == arm64 ]]; then
deps_cache_key='${{ needs.build-deps-macos-arm64.outputs.cache-key }}'
deps_cache_path='${{ needs.build-deps-macos-arm64.outputs.tar }}'
elif [[ "$os" == windows-* && "$arch" == AMD64 ]]; then
deps_cache_key='${{ needs.build-deps-windows-x86.outputs.cache-key }}'
deps_cache_path='${{ needs.build-deps-windows-x86.outputs.tar }}'
else
1>&2 echo 'Unknown OS "${{ matrix.os }}" and/or architecture "${{ matrix.arch }}"'
exit 1
fi
{
echo "deps-key=${deps_cache_key}"
echo "deps-path=${deps_cache_path}"
} | tee -a "$GITHUB_OUTPUT"
- name: Restore cached dependencies
uses: actions/cache/restore@v4
with:
key: ${{ steps.cache-key.outputs.deps-key }}
path: ${{ steps.cache-key.outputs.deps-path }}
fail-on-cache-miss: true
- name: Unpack dependencies (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: zstd -dv '${{ steps.cache-key.outputs.deps-path }}'
- name: Unpack dependencies (macOS)
if: startsWith(matrix.os, 'macos')
run: gtar -C "$TMPDIR" -xf '${{ steps.cache-key.outputs.deps-path }}'
- name: Unpack dependencies (Windows)
if: startsWith(matrix.os, 'windows')
run: tar -C "$TMPDIR" -xf "$(cygpath -u '${{ steps.cache-key.outputs.deps-path }}')"
- name: Build wheels
uses: pypa/cibuildwheel@63fd63b352a9a8bdcc24791c9dbee952ee9a8abc # v3.3.0
with:
only: ${{ matrix.wheel-config }}
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_ENVIRONMENT_LINUX: >
CC=clang
CXX=clang++
PIP_VERBOSE=1
CMAKE_AR=llvm-ar
CMAKE_LINKER_TYPE=LLD
CMAKE_PREFIX_PATH='/${{ env.TMPDIR }}/deps/cmake'
CMAKE_RANLIB=llvm-ranlib
HICTKPY_CXX_STANDARD=23
HICTKPY_PROJECT_TOP_LEVEL_INCLUDES=''
UV_LINK_MODE=copy
CIBW_ENVIRONMENT_MACOS: >
CC=clang
CXX=clang++
PIP_VERBOSE=1
CMAKE_PREFIX_PATH='${{ env.TMPDIR }}/deps/cmake'
HICTKPY_CXX_STANDARD=23
HICTKPY_OSX_DEPLOYMENT_TARGET=14.0
HICTKPY_PROJECT_TOP_LEVEL_INCLUDES=''
MACOSX_DEPLOYMENT_TARGET=14.0
UV_LINK_MODE=copy
CIBW_ENVIRONMENT_WINDOWS: >
PIP_VERBOSE=1
CMAKE_PREFIX_PATH='${{ env.TMPDIR }}\\deps\\cmake'
HICTKPY_BUILD_PORTABLE_WHEELS_WIN=ON
HICTKPY_CXX_STANDARD=23
HICTKPY_PROJECT_TOP_LEVEL_INCLUDES=''
UV_LINK_MODE=copy
CIBW_ENVIRONMENT_PASS_LINUX: >
CC
CXX
PIP_VERBOSE
CMAKE_AR
CMAKE_LINKER_TYPE
CMAKE_PREFIX_PATH
CMAKE_RANLIB
HICTKPY_CXX_STANDARD
HICTKPY_PROJECT_TOP_LEVEL_INCLUDES
UV_LINK_MODE
- name: Verify clean directory
run: git diff --exit-code
- name: Upload wheels
uses: actions/upload-artifact@v5
with:
name: "wheels-${{ matrix.wheel-config }}"
path: wheelhouse/*.whl
if-no-files-found: error
retention-days: 1
package-artifacts:
name: Package artifacts
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels
steps:
- name: Download artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
- name: Archive artifacts
run: |
mkdir dist/
find artifacts -type f -name "hictkpy*.whl" -exec cp '{}' dist/ \;
find artifacts -type f -name "hictkpy*.tar.gz" -exec cp '{}' dist/ \;
tar -cf dist.tar dist/
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: dist
path: dist.tar
if-no-files-found: error
retention-days: 7
pypi-publish:
name: Upload release to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
needs: [package-artifacts]
environment:
name: PyPI
url: https://pypi.org/p/hictkpy
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: dist
merge-multiple: true
- name: Extract dist.tar
run: |
tar -xf dist.tar
rm dist.tar
- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
attestations: true
print-hash: true
verbose: true
build-wheels-status-check:
name: Status Check (Build wheels)
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels
- package-artifacts
- pypi-publish
steps:
- name: Collect job results
if: |
needs.build-sdist.result != 'success' ||
needs.build-wheels.result != 'success' ||
needs.package-artifacts.result != 'success' ||
(
needs.pypi-publish.result != 'success' &&
needs.pypi-publish.result != 'skipped'
)
run: exit 1