From e76a43a7ee684c0d8ca3e6d57033f664cae35635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 21 Jan 2026 11:51:50 +0100 Subject: [PATCH] WIP: build on arm when releasing See https://docs.docker.com/build/ci/github-actions/multi-platform/ --- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6cebbdf..9c72efa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,6 @@ jobs: run: echo "php_versions=$(make _versions)" >> "$GITHUB_ENV" build: name: PHP - runs-on: ubuntu-24.04 needs: php-versions if: >- ${{ github.event.workflow_run.conclusion == 'success' }} @@ -31,6 +30,13 @@ jobs: fail-fast: false matrix: php: ${{ fromJSON(needs.php-versions.outputs.matrix) }} + platform: [linux/arm64, linux/amd64] + include: + - platform: linux/arm64 + runner: ubuntu-24.04-arm + - platform: linux/amd64 + runner: ubuntu-24.04 + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v6 - name: Set up QEMU @@ -38,23 +44,18 @@ jobs: - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ github.token }} - name: Build PHP ${{ matrix.php }} + id: build uses: docker/build-push-action@v6 with: file: "Dockerfile" builder: ${{ steps.buildx.outputs.name }} - push: true context: . - platforms: linux/amd64,linux/arm64 + platforms: ${{ matrix.platform }} build-args: "php=${{ matrix.php }}" cache-from: type=gha cache-to: type=gha,mode=max + outputs: type=image,push-by-digest=true,name-canonical=true,push=true labels: | org.opencontainers.image.title=PHP ${{ matrix.php }} org.opencontainers.image.description=Docker image for PHP ${{ matrix.php }} FPM @@ -63,6 +64,48 @@ jobs: org.opencontainers.image.revision=${{ github.sha }} tags: | ghcr.io/${{ github.repository }}:${{ matrix.php }} + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + - name: Upload digest + uses: actions/upload-artifact@v6 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + merge: + runs-on: ubuntu-24.04 + needs: + - build + steps: + - name: Download digests + uses: actions/download-artifact@v7 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ matrix.php }} + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create "$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${DOCKER_METADATA_OUTPUT_JSON}") $(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)" cleanup: name: Cleanup runs-on: ubuntu-24.04