Skip to content

Build + Release Wheels #110

Build + Release Wheels

Build + Release Wheels #110

Workflow file for this run

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: "${{ matrix.os }} :: ${{ matrix.arch }} (skip: ${{ matrix.skip }})"
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch: ["aarch64", "ppc64le", "s390x", "x86_64", "i686"]
skip: ["*manylinux*", "*musllinux*"]
include:
# initially generate all 10 matrix combinations with qemu on ubuntu:
- os: ubuntu-latest
use_qemu: true
# modify the x86_64 and i686 jobs generated above to disable qemu
- os: ubuntu-latest
arch: "x86_64"
use_qemu: false
- os: ubuntu-latest
arch: "i686"
use_qemu: false
# additional runs (they define skip="" to ensure they cannot be combined with any matrix combinations)
- os: windows-latest
arch: "AMD64"
use_qemu: false
skip: ""
- os: windows-latest
arch: "x86"
use_qemu: false
skip: ""
- os: macos-latest
arch: "x86_64"
use_qemu: false
skip: ""
# SSC self-hosted mac arm64 runner
- os: macos-arm64-ssc
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: 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/[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_SKIP: "${{ matrix.skip }}"
- uses: actions/upload-artifact@v4
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
with:
name: artifacts-wheels-${{ strategy.job-index }}
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 [email protected]
- 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
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/[email protected]
if: github.event.inputs.deploy_to_testpypi == 'false'
- name: Upload to TestPyPI
uses: pypa/[email protected]
if: github.event.inputs.deploy_to_testpypi == 'true'
with:
repository_url: https://test.pypi.org/legacy/