Skip to content

Update build.yml

Update build.yml #789

Workflow file for this run

name: Build
on:
workflow_dispatch:
inputs:
useCache:
description: Use GHA cache
type: boolean
required: false
default: true
push:
branches-ignore:
- "update-dependencies-pr"
paths:
- ".github/workflows/build.yml"
- "docker/**"
- "tests/**"
- "*.sh"
pull_request:
paths:
- ".github/workflows/build.yml"
- "docker/**"
- "tests/**"
- "*.sh"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- id: matrix
name: build matrix
run: |
jq --version
QUERY='reduce .[] as $platform ([]; . += reduce $platform.policies.[] as $policy ([];. += [{policy: $policy, platform: $platform.platform, runner: $platform.runner}]))'
echo "${QUERY}"
JSON=$(cat << EOF | jq -c "${QUERY}"
[
{"platform": "x86_64", "runner": "ubuntu-22.04", "policies": ["manylinux2014", "manylinux_2_28", "manylinux_2_34", "musllinux_1_2"]},
{"platform": "aarch64", "runner": "ubuntu-22.04", "policies": ["manylinux2014", "manylinux_2_28", "manylinux_2_34", "musllinux_1_2"]},
{"platform": "i686", "runner": "ubuntu-22.04", "policies": ["manylinux2014", "musllinux_1_2"]},
{"platform": "armv7l", "runner": "ubuntu-22.04", "policies": ["manylinux_2_31", "musllinux_1_2"]}
]
EOF
)
echo "matrix=${JSON}" >> $GITHUB_OUTPUT
build_manylinux:
name: ${{ matrix.policy }}_${{ matrix.platform }}
needs: build_matrix
runs-on: ${{ matrix.runner }}
permissions:
actions: write # this permission is needed to delete cache
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.build_matrix.outputs.matrix) }}
env:
POLICY: ${{ matrix.policy }}
PLATFORM: ${{ matrix.platform }}
COMMIT_SHA: ${{ github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 50
- name: Set up emulation
if: matrix.platform != 'i686' && matrix.platform != 'x86_64'
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Restore cache
if: github.event_name != 'workflow_dispatch' || fromJSON(github.event.inputs.useCache)
uses: actions/cache/restore@v4
with:
path: .buildx-cache-${{ matrix.policy }}_${{ matrix.platform }}/*
key: buildx-cache-${{ matrix.policy }}-${{ matrix.platform }}
- name: Build
run: ./build.sh
- name: Delete cache
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
KEY="buildx-cache-${{ matrix.policy }}-${{ matrix.platform }}"
gh cache delete ${KEY} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save cache
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
with:
path: .buildx-cache-${{ matrix.policy }}_${{ matrix.platform }}/*
key: buildx-cache-${{ matrix.policy }}-${{ matrix.platform }}
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'pypa/manylinux'
run: ./deploy.sh
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
all_passed:
needs: [build_manylinux]
runs-on: ubuntu-latest
steps:
- run: echo "All jobs passed"