Split wheels #1251
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 Python Wheels | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 6 * * *" # Daily 6AM UTC build | |
jobs: | |
define-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.merged-identifiers.outputs.merged-identifiers }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
cache: pip | |
- name: Install jq | |
run: sudo apt-get update && sudo apt-get install -y jq | |
- name: Install cibuildwheel | |
run: pip install cibuildwheel | |
- name: Find build identifiers using cibuildwheel --print-build-identifiers | |
id: all-build-identifiers | |
run: | | |
echo "linux=$(cibuildwheel --platform linux --print-build-identifiers | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
echo "macos=$(cibuildwheel --platform macos --print-build-identifiers | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
echo "windows=$(cibuildwheel --platform windows --print-build-identifiers | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
- name: Select build identifiers | |
id: select-build-identifiers | |
run: | | |
if [[ "$GITHUB_REF" = "refs/heads/main" ]] || [[ "$GITHUB_REF" = "refs/heads/master" ]] || [[ "$GITHUB_REF" = "refs/tags/"* ]]; then | |
echo 'linux=${{ steps.all-build-identifiers.outputs.linux }}' >> $GITHUB_OUTPUT | |
echo 'windows=${{ steps.all-build-identifiers.outputs.windows }}' >> $GITHUB_OUTPUT | |
echo 'macos=${{ steps.all-build-identifiers.outputs.macos }}' >> $GITHUB_OUTPUT | |
else | |
echo "linux=$(echo -n '${{ steps.all-build-identifiers.outputs.linux }}' | awk '{print $NF}')" >> $GITHUB_OUTPUT | |
echo "macos=$(echo -n '${{ steps.all-build-identifiers.outputs.macos }}' | awk '{print $NF}')" >> $GITHUB_OUTPUT | |
echo "windows=$(echo -n '${{ steps.all-build-identifiers.outputs.windows }}' | awk '{print $NF}')" >> $GITHUB_OUTPUT | |
fi | |
- name: Output build identifiers | |
id: json-identifiers | |
run: | | |
echo "linux=$(echo -n '${{ steps.select-build-identifiers.outputs.linux }}' | jq -R -s -c 'split(" ") | map(select(length > 0)) | [.[] | {os: "ubuntu-latest", "build-identifier": .}]')" >> $GITHUB_OUTPUT | |
echo "macos=$(echo -n '${{ steps.select-build-identifiers.outputs.macos }}' | jq -R -s -c 'split(" ") | map(select(length > 0)) | [.[] | {os: "macos-latest", "build-identifier": .}]')" >> $GITHUB_OUTPUT | |
echo "windows=$(echo -n '${{ steps.select-build-identifiers.outputs.windows }}' | jq -R -s -c 'split(" ") | map(select(length > 0)) | [.[] | {os: "windows-latest", "build-identifier": .}]')" >> $GITHUB_OUTPUT | |
- name: Merge build identifiers | |
id: merged-identifiers | |
run: | | |
echo merged-identifiers=$(echo -n '${{ steps.json-identifiers.outputs.linux }} ${{ steps.json-identifiers.outputs.macos }} ${{ steps.json-identifiers.outputs.windows }}' | jq -c -s 'add') >> $GITHUB_OUTPUT | |
build-wheels: | |
runs-on: ${{ matrix.os }} | |
needs: define-matrix | |
strategy: | |
matrix: | |
include: ${{ fromJSON(needs.define-matrix.outputs.matrix ) }} | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- name: Install native dependencies (Ubuntu) | |
run: sudo apt-get update && sudo apt-get install -y libgpgme-dev libgpg-error-dev | |
if: "matrix.os == 'ubuntu-latest'" | |
- name: set up rust | |
if: matrix.os != 'ubuntu' | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
override: true | |
- name: Install native dependencies (MacOS) | |
run: brew install swig gpgme | |
if: "matrix.os == 'macos-latest'" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel cibuildwheel | |
- name: Provide gpgme-config and gpg-error-config | |
if: "matrix.os == 'ubuntu-latest'" | |
run: | | |
mkdir -p "$HOME/.local/bin" | |
cp .github/gpgme-config "$HOME/.local/bin/gpgme-config" | |
cp .github/gpg-error-config "$HOME/.local/bin/gpg-error-config" | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Install gpg on supported platforms | |
run: pip install -U gpg | |
if: "matrix.os != 'windows-latest'" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
if: "matrix.os == 'ubuntu-latest'" | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_MACOS: x86_64 arm64 universal2 | |
CIBW_BUILD: "${{ matrix.build-identifier }}*" | |
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" PYO3_USE_ABI3_FORWARD_COMPATIBILITY="1" MACOSX_DEPLOYMENT_TARGET="10.12"' | |
CIBW_BEFORE_BUILD: > | |
pip install -U setuptools-rust && | |
rustup default nightly && | |
rustup target add all && | |
rustup show | |
CIBW_BEFORE_BUILD_LINUX: > | |
pip install -U setuptools-rust && | |
yum install libatomic -y && | |
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && | |
rustup target add all && | |
rustup show | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ matrix.build-identifier }} | |
path: ./wheelhouse/*.whl | |
publish: | |
runs-on: ubuntu-latest | |
needs: build-wheels | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/brz-') | |
permissions: | |
id-token: write | |
environment: | |
name: pypi | |
url: https://pypi.org/p/breezy | |
steps: | |
- name: Download distributions | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
pattern: artifact-* | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |