From b241b59a944b4947ba3634f87d24b39d74124809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20A=2E=20Matienzo?= Date: Tue, 16 Dec 2025 12:41:54 -0800 Subject: [PATCH 1/2] fix multiplatform builds refs BerkeleyLibrary/gha-testing#3 --- .github/workflows/build.yml | 33 +++++++++++++++++++++------------ .github/workflows/release.yml | 9 +++++---- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d35e6b0..971e9fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,9 +19,11 @@ jobs: strategy: fail-fast: false matrix: - runner: - - ubuntu-24.04 - - ubuntu-24.04-arm + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + - platform: linux/arm64 + runner: ubuntu-24.04-arm steps: - name: Checkout code uses: actions/checkout@v4 @@ -37,7 +39,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - id: build-meta - name: Docker meta + name: Prepare Docker metadata uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} @@ -45,7 +47,7 @@ jobs: # Build cache is shared among all builds of the same architecture - id: cache-meta - name: Docker meta + name: Fetch build cache metadata uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} @@ -60,6 +62,7 @@ jobs: name: Build/push the arch-specific image uses: docker/build-push-action@v6 with: + platforms: ${{ matrix.platform }} cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }} cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max labels: ${{ steps.build-meta.outputs.labels }} @@ -74,13 +77,15 @@ jobs: echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT" merge: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: build env: DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.image-arm64 }} DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.image-x64 }} outputs: image: ${{ steps.meta.outputs.tags }} + build-image-arm64: ${{ needs.build.outputs.image-arm64 }} + build-image-x64: ${{ needs.build.outputs.image-x64 }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -100,7 +105,8 @@ jobs: uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} - tags: type=sha,suffix=${{ env.BUILD_SUFFIX }} + tags: | + type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }} - name: Push the multi-platform app image run: | @@ -109,7 +115,7 @@ jobs: "$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64" test: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: merge env: COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml @@ -137,16 +143,20 @@ jobs: docker compose exec app test/test.sh push: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: - merge - test env: DOCKER_APP_IMAGE: ${{ needs.merge.outputs.image }} + DOCKER_APP_IMAGE_ARM64: ${{ needs.merge.outputs.build-image-arm64 }} + DOCKER_APP_IMAGE_X64: ${{ needs.merge.outputs.build-image-x64 }} steps: - name: Checkout code uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -165,6 +175,5 @@ jobs: - name: Retag and push the image run: | - docker pull "$DOCKER_APP_IMAGE" - echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE" - docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)" + docker buildx imagetools create \ + $(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") $DOCKER_APP_IMAGE_ARM64 $DOCKER_APP_IMAGE_X64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d90890..65f1b3f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: env: BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }} run: | - docker pull "$BASE_IMAGE" + docker manifest inspect "$BASE_IMAGE" - name: Produce release tags id: tag-meta @@ -51,9 +51,10 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{version}} - - name: Retag the pulled image + - name: Retag and push image env: BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }} run: | - echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$BASE_IMAGE" - docker push --all-tags "$(echo "$BASE_IMAGE" | cut -f1 -d:)" + docker buildx imagetools create \ + $(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + "$(echo "$BASE_IMAGE" | cut -f1 -d:)" From b4ec54d3aed84dbedf6d5188d74efa0939a7c0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20A=2E=20Matienzo?= Date: Wed, 17 Dec 2025 11:22:33 -0800 Subject: [PATCH 2/2] make whitespace consistent --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 971e9fb..56fc3da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -157,6 +157,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: