Skip to content

Commit 6ce4f92

Browse files
committed
fix multiplatform builds
ref BerkeleyLibrary/gha-testing#3
1 parent dd61e3d commit 6ce4f92

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
runner:
24-
- ubuntu-24.04
25-
- ubuntu-24.04-arm
23+
include:
24+
- platform: linux/amd64
25+
runner: ubuntu-24.04
26+
- platform: linux/arm64
27+
runner: ubuntu-24.04-arm
2628
steps:
2729
- name: Checkout code
2830
uses: actions/checkout@v4
@@ -66,6 +68,7 @@ jobs:
6668
name: Build/push the arch-specific image
6769
uses: docker/build-push-action@v6
6870
with:
71+
platforms: ${{ matrix.platform }}
6972
build-args: |
7073
BUILD_TIMESTAMP=${{ github.event.repository.updated_at }}
7174
BUILD_URL=${{ steps.set_build_url.outputs.build_url }}
@@ -86,14 +89,16 @@ jobs:
8689
echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"
8790
8891
merge:
89-
runs-on: ubuntu-24.04
92+
runs-on: ubuntu-latest
9093
needs:
9194
- build
9295
env:
9396
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.build-image-arm }}
9497
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.build-image-x64 }}
9598
outputs:
9699
build-image: ${{ steps.meta.outputs.tags }}
100+
build-image-arm: ${{ needs.build.outputs.build-image-arm }}
101+
build-image-x64: ${{ needs.build.outputs.build-image-x64 }}
97102
steps:
98103
- name: Checkout code
99104
uses: actions/checkout@v4
@@ -123,7 +128,7 @@ jobs:
123128
"$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64"
124129
125130
test:
126-
runs-on: ubuntu-24.04
131+
runs-on: ubuntu-latest
127132
needs:
128133
- merge
129134
env:
@@ -152,16 +157,21 @@ jobs:
152157
docker compose exec app bin/test
153158
154159
push:
155-
runs-on: ubuntu-24.04
160+
runs-on: ubuntu-latest
156161
needs:
157162
- merge
158163
- test
159164
env:
160165
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.build-image }}
166+
DOCKER_APP_IMAGE_ARM64: ${{ needs.merge.outputs.build-image-arm }}
167+
DOCKER_APP_IMAGE_X64: ${{ needs.merge.outputs.build-image-x64 }}
161168
steps:
162169
- name: Checkout code
163170
uses: actions/checkout@v4
164171

172+
- name: Set up Docker Buildx
173+
uses: docker/setup-buildx-action@v3
174+
165175
- name: Login to GitHub Container Registry
166176
uses: docker/login-action@v3
167177
with:
@@ -181,6 +191,5 @@ jobs:
181191
182192
- name: Retag and push the image
183193
run: |
184-
docker pull "$DOCKER_APP_IMAGE"
185-
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE"
186-
docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)"
194+
docker buildx imagetools create \
195+
$(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") $DOCKER_APP_IMAGE_ARM64 $DOCKER_APP_IMAGE_X64

.github/workflows/release.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ jobs:
1717
- name: Checkout code
1818
uses: actions/checkout@v4
1919

20-
- name: Set up QEMU
21-
uses: docker/setup-qemu-action@v3
22-
2320
- name: Set up Docker Buildx
2421
uses: docker/setup-buildx-action@v3
2522

@@ -41,7 +38,7 @@ jobs:
4138
env:
4239
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
4340
run: |
44-
docker pull "$BASE_IMAGE"
41+
docker manifest inspect "$BASE_IMAGE"
4542
4643
- name: Produce release tags
4744
id: tag-meta
@@ -59,5 +56,6 @@ jobs:
5956
env:
6057
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
6158
run: |
62-
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$BASE_IMAGE"
63-
docker push --all-tags "$(echo "$BASE_IMAGE" | cut -f1 -d:)"
59+
docker buildx imagetools create \
60+
$(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
61+
"$(echo "$BASE_IMAGE" | cut -f1 -d:)"

0 commit comments

Comments
 (0)