Skip to content

Commit

Permalink
Fully skip qemu jobs if requested in workflow dispatch
Browse files Browse the repository at this point in the history
- job matrix `use_qemu[bool]` -> `emulation[str]`
- workflow dispatch input `skip_qemu[str]` -> `skip_emulation[str]`
- default skip_emulation = "" and no jobs are skipped
- with skip_emulation = "qemu" the qemu jobs are removed from the matrix
- simplify some conditional logic in the steps
  • Loading branch information
lkeegan committed Jun 11, 2024
1 parent 9b20a6d commit fce84b1
Showing 1 changed file with 57 additions and 56 deletions.
113 changes: 57 additions & 56 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ name: Build + Release Wheels

on:
push:
tags:
- 'v?[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+'
tags:
- 'v?[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+'
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
Expand All @@ -19,58 +15,65 @@ on:
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

env:
USE_QEMU: ${{ github.event.inputs.use_qemu == 'true' }}

jobs:
build-wheels:
name: "${{ matrix.os }} :: ${{ matrix.platform }}-${{ matrix.arch }}"
runs-on: ${{ matrix.os }}

strategy:
matrix:
arch: ["aarch64", "ppc64le", "s390x", "x86_64", "i686"]
# 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:
# initially generate all 10 matrix combinations with qemu on ubuntu:
# linux
- os: ubuntu-latest
use_qemu: true
# modify the x86_64 and i686 jobs generated above to disable qemu
platform: "manylinux"
arch: "x86_64"
- os: ubuntu-latest
platform: "manylinux"
arch: "i686"
- os: ubuntu-latest
platform: "musllinux"
arch: "x86_64"
use_qemu: false
- os: ubuntu-latest
platform: "musllinux"
arch: "i686"
use_qemu: false
# additional runs
# windows
- os: windows-latest
platform: "win"
arch: "AMD64"
use_qemu: false
- os: windows-latest
platform: "win"
arch: "x86"
use_qemu: false
# macos
- os: macos-13
platform: "macos"
arch: "x86_64"
use_qemu: false
- os: macos-14
- os: macos-latest
platform: "macos"
arch: "arm64"
use_qemu: false

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))
- name: Support long paths on Windows
if: runner.os == 'Windows'
run: git config --system core.longpaths true

- name: Set up msvc on Windows
Expand All @@ -87,18 +90,16 @@ jobs:
- name: Set up QEMU
uses: docker/[email protected]
if: runner.os == 'Linux' && ((matrix.use_qemu) && fromJSON(env.USE_QEMU))
if: runner.os == 'Linux' && matrix.emulation == 'qemu'

- name: Build wheels
uses: pypa/[email protected]
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
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
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
with:
name: artifacts-wheels-${{ matrix.platform }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -160,31 +161,31 @@ jobs:
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/[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/

- name: GitHub release for tagged commits
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
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/[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/

- name: GitHub release for tagged commits
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')

0 comments on commit fce84b1

Please sign in to comment.