Build + Release Wheels #51
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: | |
workflow_dispatch: | |
inputs: | |
use_qemu: | |
description: "Use qemu for builds with targets requiring emulation" | |
required: true | |
default: true | |
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" | |
deploy_to_testpypi: | |
description: "Whether the build should be deployed to test.pypi.org instead regular PyPI" | |
required: true | |
default: false | |
env: | |
USE_QEMU: ${{ github.event.inputs.use_qemu == 'true' }} | |
jobs: | |
build-wheels: | |
name: Build wheels on ${{ matrix.os }} (arch=${{ matrix.arch }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
arch: "x86_64" | |
use_qemu: false | |
skip: "*manylinux*" | |
- os: ubuntu-22.04 | |
arch: "x86_64" | |
use_qemu: false | |
skip: "*musllinux*" | |
- os: ubuntu-22.04 | |
arch: "i686" | |
use_qemu: false | |
skip: "*manylinux*" | |
- os: ubuntu-22.04 | |
arch: "i686" | |
use_qemu: false | |
skip: "*musllinux*" | |
# These take too long to build on Github | |
#- os: ubuntu-20.04 | |
#arch: "aarch64" | |
#use_qemu: true | |
#- os: ubuntu-20.04 | |
#arch: "ppc64le" | |
#use_qemu: true | |
#- os: ubuntu-20.04 | |
#arch: "s390x" | |
#use_qemu: true | |
- os: windows-2022 | |
arch: "AMD64" | |
use_qemu: false | |
skip: "" | |
- os: windows-2022 | |
arch: "x86" | |
use_qemu: false | |
skip: "" | |
- os: macos-11 | |
arch: "x86_64" | |
use_qemu: false | |
skip: "" | |
- os: macos-11 | |
arch: "arm64" | |
use_qemu: false | |
skip: "" | |
steps: | |
- uses: actions/checkout@v4 | |
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) | |
- name: Support long paths | |
if: runner.os == 'Windows' && ((!matrix.use_qemu) || fromJSON(env.USE_QEMU)) | |
run: git config --system core.longpaths true | |
- name: Export macOS SDKROOT | |
if: runner.os == 'macOS' | |
run: echo SDKROOT=$(xcrun --sdk macosx --show-sdk-path) >> $GITHUB_ENV | |
- name: Override LLVM version (${{ github.event.inputs.llvm_version }}) | |
if: github.event.inputs.llvm_version | |
run: | | |
echo "set(CLANG_TIDY_VERSION ${{ github.event.inputs.llvm_version }})" > clang-tidy_version.cmake | |
echo "set(CLANG_TIDY_WHEEL_VERSION ${{ github.event.inputs.wheel_version }})" >> clang-tidy_version.cmake | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
if: runner.os == 'Linux' && ((matrix.use_qemu) && fromJSON(env.USE_QEMU)) | |
- name: Build wheels | |
uses: pypa/[email protected] | |
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) | |
env: | |
CIBW_ARCHS: "${{ matrix.arch }}" | |
CIBW_BEFORE_TEST: rm -rf {package}/clang_tidy | |
CIBW_TEST_SKIP: "*linux*" | |
CIBW_SKIP: "${{matrix.skip}}" | |
# clang-tidy simply does not want to cooperate with the github linux image | |
- name: Test Linux Wheel | |
if: runner.os == 'Linux' && !(matrix.use_qemu) && matrix.arch == 'x86_64' | |
run: | | |
if [[ "${{matrix.skip}}" == "*manylinux*" ]] ; then | |
docker build --build-arg BASEOS=alpine3.16 --build-arg PLATFORM=musllinux -f .github/workflows/Dockerfile . | |
else | |
docker build --build-arg BASEOS=slim-bullseye --build-arg PLATFORM=manylinux -f .github/workflows/Dockerfile . | |
fi | |
- name: Set artifact name | |
id: set_artifact_name | |
shell: bash -l {0} | |
run: | | |
VALUE="archive_wheels_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.skip }}" | |
VALUE="${VALUE//\*/}" | |
echo "value=${VALUE}" >> ${GITHUB_OUTPUT} | |
- uses: actions/upload-artifact@v4 | |
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) | |
with: | |
path: ./wheelhouse/*.whl | |
name: ${{ steps.set_artifact_name.outputs.value }} | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Override LLVM version (${{ github.event.inputs.llvm_version }}) | |
if: github.event.inputs.llvm_version | |
run: | | |
echo "set(CLANG_TIDY_VERSION ${{ github.event.inputs.llvm_version }})" > clang-tidy_version.cmake | |
echo "set(CLANG_TIDY_WHEEL_VERSION ${{ github.event.inputs.wheel_version }})" >> clang-tidy_version.cmake | |
- name: Build SDist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
name: archive_sdist | |
test-sdist: | |
name: Test build from source distribution | |
needs: [build-sdist] | |
runs-on: ubuntu-22.04 | |
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: archive_sdist | |
path: sdist | |
- name: Install from SDist | |
run: | | |
# make sure the test will not pick this up | |
rm -r clang_tidy | |
pip install sdist/*.tar.gz | |
- name: Install test requirements | |
run: | |
python -m pip install -r requirements-dev.txt | |
- name: Run test suite | |
run: | |
python -m pytest | |
upload_pypi: | |
name: Upload to PyPI | |
needs: [build-wheels, build-sdist, test-sdist] | |
runs-on: ubuntu-22.04 | |
if: github.repository_owner == 'ssciwr' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: archive* | |
path: dist | |
merge-multiple: true | |
- name: Upload to PyPI | |
uses: pypa/[email protected] | |
if: github.event.inputs.deploy_to_testpypi == 'false' | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Upload to TestPyPI | |
uses: pypa/[email protected] | |
if: github.event.inputs.deploy_to_testpypi == 'true' | |
with: | |
user: __token__ | |
password: ${{ secrets.TESTPYPI_API_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ |