From 440640eede0b1c873aae414f4ee8e71504aa94eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Lain=C3=A9?= Date: Wed, 23 Feb 2022 23:15:15 +0100 Subject: [PATCH] Rework multi-stage build to allow multiple archs --- .github/workflows/build-ffmpeg.yml | 71 +++++++++++++----------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build-ffmpeg.yml b/.github/workflows/build-ffmpeg.yml index f3e61364..dc58c0ed 100644 --- a/.github/workflows/build-ffmpeg.yml +++ b/.github/workflows/build-ffmpeg.yml @@ -51,13 +51,12 @@ jobs: name: output path: output/ - build-aarch64-stage-1: - name: build (ubuntu-latest, aarch64) stage-1 + build-qemu-stage-1: runs-on: ubuntu-latest + strategy: + matrix: + arch: [aarch64] env: - pybin: /opt/python/cp38-cp38/bin - vendor: /tmp/vendor - img: quay.io/pypa/manylinux2014_aarch64 stage: 1 steps: - uses: actions/checkout@v2 @@ -66,33 +65,27 @@ jobs: python-version: 3.8 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - - uses: actions/cache@v2 - id: libs-cache - with: - path: vendor - key: ${{ runner.os }}-aarch64-libs-cache-${{ env.stage }}-${{ hashFiles('**/build-ffmpeg.py') }} - name: Build FFmpeg dependencies - if: ${{ steps.libs-cache.outputs.cache-hit != 'true' }} run: | - docker run -v $PWD:/project:rw --workdir=/project ${{ env.img }} bash -exc ' - export PATH=${{ env.pybin }}:$PATH; + docker run -v $PWD:/project:rw --workdir=/project quay.io/pypa/manylinux2014_${{ matrix.arch }} bash -exc ' + export PATH=/opt/python/cp38-cp38/bin:$PATH; export CIBUILDWHEEL=1; - python scripts/build-ffmpeg.py ${{ env.vendor }} ${{ env.stage }}; - cp -ar ${{ env.vendor }} /project; + python scripts/build-ffmpeg.py /tmp/vendor ${{ env.stage }}; + cp -ar /tmp/vendor /project; ' shell: bash - uses: actions/upload-artifact@v2 with: - name: artifacts + name: artifacts-${{ matrix.arch }} path: vendor - build-aarch64-stage-2: - name: build (ubuntu-latest, aarch64) stage-2 - needs: build-aarch64-stage-1 + + build-qemu-stage-2: + needs: build-qemu-stage-1 runs-on: ubuntu-latest + strategy: + matrix: + arch: [aarch64] env: - pybin: /opt/python/cp38-cp38/bin - vendor: /tmp/vendor - img: quay.io/pypa/manylinux2014_aarch64 stage: 2 steps: - uses: actions/checkout@v2 @@ -103,34 +96,30 @@ jobs: uses: docker/setup-qemu-action@v1 - uses: actions/download-artifact@v2 with: - name: artifacts + name: artifacts-${{ matrix.arch }} path: vendor - - uses: actions/cache@v2 - id: libs-cache - with: - path: vendor - key: ${{ runner.os }}-aarch64-libs-cache-${{ env.stage }}-${{ hashFiles('**/build-ffmpeg.py') }} - name: Build FFmpeg dependencies - if: ${{ steps.libs-cache.outputs.cache-hit != 'true' }} run: | - docker run -v $PWD:/project:rw --workdir=/project ${{ env.img }} bash -exc ' - export PATH=${{ env.pybin }}:$PATH; + docker run -v $PWD:/project:rw --workdir=/project quay.io/pypa/manylinux2014_${{ matrix.arch }} bash -exc ' + export PATH=/opt/python/cp38-cp38/bin:$PATH; export CIBUILDWHEEL=1; cp -ar vendor /tmp; - python scripts/build-ffmpeg.py ${{ env.vendor }} ${{ env.stage }}; - cp -ar ${{ env.vendor }} /project; + python scripts/build-ffmpeg.py /tmp/vendor ${{ env.stage }}; + cp -ar /tmp/vendor /project; ' shell: bash - uses: actions/upload-artifact@v2 with: - name: artifacts + name: artifacts-${{ matrix.arch }} path: vendor - build-aarch64-stage-final: - name: build (ubuntu-latest, aarch64) stage-final - needs: build-aarch64-stage-2 + + build-qemu-stage-3: + needs: build-qemu-stage-2 runs-on: ubuntu-latest + strategy: + matrix: + arch: [aarch64] env: - vendor: /tmp/vendor stage: 3 steps: - uses: actions/checkout@v2 @@ -141,13 +130,13 @@ jobs: uses: docker/setup-qemu-action@v1 - uses: actions/download-artifact@v2 with: - name: artifacts + name: artifacts-${{ matrix.arch }} path: vendor - name: Build FFmpeg env: - CIBW_ARCHS: aarch64 + CIBW_ARCHS: ${{ matrix.arch }} CIBW_BEFORE_ALL_LINUX: cp -ar vendor /tmp - CIBW_BEFORE_BUILD: python scripts/build-ffmpeg.py ${{ env.vendor }} ${{ env.stage }} + CIBW_BEFORE_BUILD: python scripts/build-ffmpeg.py /tmp/vendor ${{ env.stage }} CIBW_BUILD: cp38-* CIBW_REPAIR_WHEEL_COMMAND_LINUX: LD_LIBRARY_PATH=/tmp/vendor/lib:$LD_LIBRARY_PATH auditwheel repair -w {dest_dir} {wheel} CIBW_SKIP: "*musllinux*"