From bebdb6fa2a18c63a59caafbab6add8fb6115bb79 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 28 Mar 2023 04:22:16 +0200 Subject: [PATCH] ci: enhanced build workflow Signed-off-by: CrazyMax --- .github/workflows/build.yml | 71 ++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d78258cc6..2af6f0fe59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,14 +15,35 @@ on: pull_request: jobs: + prepare: + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.platforms.outputs.matrix }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Create matrix + id: platforms + run: | + echo "matrix=$(docker buildx bake cross --print | jq -cr '.target."cross".platforms')" >>${GITHUB_OUTPUT} + - + name: Show matrix + run: | + echo ${{ steps.platforms.outputs.matrix }} + build: runs-on: ubuntu-20.04 + needs: + - prepare strategy: fail-fast: false matrix: target: - - cross - - dynbinary-cross + - binary + - dynbinary + platform: ${{ fromJson(needs.prepare.outputs.matrix) }} use_glibc: - "" - glibc @@ -36,22 +57,22 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Run ${{ matrix.target }} + name: Build uses: docker/bake-action@v2 with: targets: ${{ matrix.target }} + set: | + *.platform=${{ matrix.platform }} env: USE_GLIBC: ${{ matrix.use_glibc }} - - name: Flatten artifacts + name: Create tarball working-directory: ./build run: | - for dir in */; do - base=$(basename "$dir") - echo "Creating ${base}.tar.gz ..." - tar -cvzf "${base}.tar.gz" "$dir" - rm -rf "$dir" - done + mkdir /tmp/out + platform=${{ matrix.platform }} + platformPair=${platform//\//-} + tar -cvzf "/tmp/out/docker-${platformPair}.tar.gz" . if [ -z "${{ matrix.use_glibc }}" ]; then echo "ARTIFACT_NAME=${{ matrix.target }}" >> $GITHUB_ENV else @@ -62,11 +83,35 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} - path: ./build/* + path: /tmp/out/* if-no-files-found: error + prepare-plugins: + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.platforms.outputs.matrix }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Create matrix + id: platforms + run: | + echo "matrix=$(docker buildx bake plugins-cross --print | jq -cr '.target."plugins-cross".platforms')" >>${GITHUB_OUTPUT} + - + name: Show matrix + run: | + echo ${{ steps.platforms.outputs.matrix }} + plugins: runs-on: ubuntu-20.04 + needs: + - prepare-plugins + strategy: + fail-fast: false + matrix: + platform: ${{ fromJson(needs.prepare-plugins.outputs.matrix) }} steps: - name: Checkout @@ -75,7 +120,9 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build plugins + name: Build uses: docker/bake-action@v2 with: targets: plugins-cross + set: | + *.platform=${{ matrix.platform }}