Merge pull request #106 from ssciwr/fix_windows_ci #139
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build + Release Wheels | |
on: | |
push: | |
tags: | |
- 'v?[0-9]+.[0-9]+.[0-9]+' | |
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+' | |
workflow_dispatch: | |
inputs: | |
llvm_version: | |
description: "LLVM version to build" | |
required: false | |
default: "" | |
wheel_version: | |
description: "Version of the wheel packaging (appended to LLVM version)" | |
required: false | |
default: "0" | |
skip_emulation: | |
description: "Emulation builds to skip (e.g. qemu)" | |
required: false | |
default: "" | |
deploy_to_testpypi: | |
description: "Whether the build should be deployed to test.pypi.org instead regular PyPI" | |
required: true | |
default: false | |
jobs: | |
build-wheels: | |
name: "${{ matrix.os }} :: ${{ matrix.platform }}-${{ matrix.arch }}" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# emulated linux: generate 6 matrix combinations with qemu on ubuntu: | |
arch: ["aarch64", "ppc64le", "s390x"] | |
platform: ["manylinux", "musllinux"] | |
os: [ubuntu-latest] | |
emulation: ["qemu"] | |
exclude: | |
# conditionally skip jobs requiring emulation: | |
- os: ubuntu-latest | |
emulation: ${{ github.event.inputs.skip_emulation }} | |
include: | |
# linux | |
- os: ubuntu-latest | |
platform: "manylinux" | |
arch: "x86_64" | |
- os: ubuntu-latest | |
platform: "manylinux" | |
arch: "i686" | |
- os: ubuntu-latest | |
platform: "musllinux" | |
arch: "x86_64" | |
- os: ubuntu-latest | |
platform: "musllinux" | |
arch: "i686" | |
# windows | |
- os: windows-2019 | |
platform: "win" | |
arch: "AMD64" | |
- os: windows-2019 | |
platform: "win" | |
arch: "x86" | |
# macos | |
- os: macos-13 | |
platform: "macos" | |
arch: "x86_64" | |
- os: macos-latest | |
platform: "macos" | |
arch: "arm64" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Support long paths on Windows | |
if: runner.os == 'Windows' | |
run: git config --system core.longpaths true | |
- name: Set up msvc on Windows | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{ matrix.arch }} | |
- name: Override LLVM version (${{ github.event.inputs.llvm_version }}) | |
if: github.event.inputs.llvm_version | |
run: | | |
echo "${{ github.event.inputs.llvm_version }}.${{ github.event.inputs.wheel_version }}" > clang-format_version.txt | |
cat clang-format_version.txt | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3.0.0 | |
if: runner.os == 'Linux' && matrix.emulation == 'qemu' | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.18 | |
env: | |
CIBW_ARCHS: "${{ matrix.arch }}" | |
# restrict to a single Python version as wheel does not depend on Python: | |
CIBW_BUILD: "cp311-${{ matrix.platform }}*" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-wheels-${{ matrix.platform }}-${{ matrix.arch }} | |
path: ./wheelhouse/*.whl | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Override LLVM version (${{ github.event.inputs.llvm_version }}) | |
if: github.event.inputs.llvm_version | |
run: | | |
echo "${{ github.event.inputs.llvm_version }}.${{ github.event.inputs.wheel_version }}" > clang-format_version.txt | |
cat clang-format_version.txt | |
- name: Build SDist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-sdist | |
path: dist/*.tar.gz | |
test-sdist: | |
name: Test build from source distribution | |
needs: [build-sdist] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.9' | |
- uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-sdist | |
path: sdist | |
- name: Install from SDist | |
run: | |
pip install sdist/*.tar.gz | |
- name: Install test requirements | |
run: | |
python -m pip install -r requirements-dev.txt | |
- name: Set up Git identity | |
run: | | |
git config --global user.name Name | |
git config --global user.email foo@bar.com | |
- name: Run test suite | |
run: | |
python -m pytest | |
upload_pypi: | |
name: Upload to PyPI | |
needs: [build-wheels, build-sdist, test-sdist] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
if: github.repository_owner == 'ssciwr' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-* | |
merge-multiple: true | |
path: dist | |
- name: Upload to PyPI | |
uses: pypa/gh-action-pypi-publish@v1.8.14 | |
if: github.event.inputs.deploy_to_testpypi == 'false' | |
- name: Upload to TestPyPI | |
uses: pypa/gh-action-pypi-publish@v1.8.14 | |
if: github.event.inputs.deploy_to_testpypi == 'true' | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
- name: GitHub release for tagged commits | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') |