Skip to content

build: scikit-build-core, QuantLib 1.41, Python 3.10-3.14, new CI #28

build: scikit-build-core, QuantLib 1.41, Python 3.10-3.14, new CI

build: scikit-build-core, QuantLib 1.41, Python 3.10-3.14, new CI #28

# builds only on the following conditions:
# - pull requests into main
# - OR pushes of tags starting with v*
# - OR manual dispatch on repo
# publishes to test pypi if:
# - in auto-differentiation/QuantLib-Risks-Py repository AND
# - pushes of tags starting with v*
# - OR manual dispatch on repo
# publishes to real PyPI if:
# - publish to Test PyPI worked (with all build conditions above)
# - and if it's a version tag (starting with v*)
#
# cibuildwheel config: [tool.cibuildwheel] in pyproject.toml
name: QuantLib-Risks wheels
on:
pull_request:
branches:
- main
push:
tags:
- v*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build_wheels:
name: Wheels ${{ matrix.platform.name }} ${{ matrix.python }}
strategy:
fail-fast: false
matrix:
python: [cp310, cp311, cp312, cp313, cp314]
platform:
- { name: manylinux-x86_64, os: ubuntu-24.04, build: "manylinux*" }
- { name: musllinux-x86_64, os: ubuntu-24.04, build: "musllinux*" }
- { name: manylinux-aarch64, os: ubuntu-24.04-arm, build: "manylinux*" }
- { name: musllinux-aarch64, os: ubuntu-24.04-arm, build: "musllinux*" }
- { name: macos-x86_64, os: macos-15-intel, build: "*" }
- { name: macos-arm64, os: macos-15, build: "*" }
- { name: windows-amd64, os: windows-2022, build: "*" }
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
persist-credentials: false
- name: Compiler cache setup
shell: bash
run: |
# outside the checkout, which is copied into the Linux build containers
echo "CCACHE_DIR=$RUNNER_TEMP/ccache" >> "$GITHUB_ENV"
echo "SCCACHE_DIR=$RUNNER_TEMP/sccache" >> "$GITHUB_ENV"
case "$RUNNER_OS" in
macOS)
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> "$GITHUB_ENV" ;;
Windows)
# sccache needs Ninja (bundled with Visual Studio), not the VS generator
echo "CMAKE_GENERATOR=Ninja" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV" ;;
esac
- name: Compiler cache
uses: hendrikmuhs/ccache-action@v1.2.24
with:
key: ${{ matrix.platform.name }}
variant: ${{ runner.os == 'Windows' && 'sccache' || 'ccache' }}
max-size: 2G
- name: MSVC environment (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: Build wheels
uses: pypa/cibuildwheel@v4.3.4
env:
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.platform.build }}
# Linux builds run in containers: ccache installed there, cache on the host (/host)
CIBW_BEFORE_ALL_LINUX: dnf install -y ccache git || apk add --no-cache ccache git
CIBW_INHERIT: "before-all-linux: prepend"
CIBW_ENVIRONMENT_LINUX: >-
CMAKE_CXX_COMPILER_LAUNCHER=ccache
CCACHE_DIR=/host${{ runner.temp }}/ccache/$AUDITWHEEL_PLAT
CCACHE_MAXSIZE=1G
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: cibw-wheels-${{ matrix.platform.name }}-${{ matrix.python }}
path: ./wheelhouse/*.whl
if-no-files-found: error
build_sdist:
name: SDist
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
persist-credentials: false
- name: Build sdist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check --strict dist/*
- name: Upload sdist
uses: actions/upload-artifact@v7
with:
name: cibw-sdist
path: dist/*.tar.gz
if-no-files-found: error
test-publish:
needs: [build_wheels, build_sdist]
if: >-
github.repository == 'auto-differentiation/QuantLib-Risks-Py' &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')))
environment:
name: testpypi
url: https://test.pypi.org/p/QuantLib-Risks
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@v1.14.3
name: Publish on Test PyPI
with:
verbose: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true
publish:
runs-on: ubuntu-latest
needs: test-publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/p/QuantLib-Risks
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@v1.14.3
name: Publish on PyPI
with:
verbose: true
skip-existing: true