Skip to content

Commit f38aa73

Browse files
authored
use arm-runners, upgrade actions, refactor merge manifest stage (#684)
1 parent dd77028 commit f38aa73

File tree

2 files changed

+117
-43
lines changed

2 files changed

+117
-43
lines changed

.github/workflows/main.yml

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,90 @@ on:
55
branches:
66
- main
77

8+
env:
9+
REGISTRY_IMAGE: thirdweb/engine
10+
811
jobs:
912
build:
10-
runs-on: ubuntu-latest
13+
runs-on: ${{ matrix.runner }}
1114
strategy:
1215
matrix:
13-
platform: [linux/amd64, linux/arm64]
14-
16+
include:
17+
- platform: linux/amd64
18+
runner: ubuntu-latest
19+
- platform: linux/arm64
20+
runner: ubuntu-24.04-arm64
1521
steps:
1622
- name: Checkout code
17-
uses: actions/checkout@v2
23+
uses: actions/checkout@v3
24+
25+
- name: Prepare
26+
run: |
27+
platform=${{ matrix.platform }}
28+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
1829
1930
- name: Set up Docker Buildx
2031
uses: docker/setup-buildx-action@v3
2132

2233
- name: Login to DockerHub
23-
uses: docker/login-action@v1
34+
uses: docker/login-action@v3
2435
with:
2536
username: ${{ secrets.DOCKER_USERNAME }}
2637
password: ${{ secrets.DOCKER_PASSWORD }}
2738

28-
- name: Build and Push Docker Image
29-
uses: docker/build-push-action@v2
39+
- name: Build and push by digest
40+
id: build
41+
uses: docker/build-push-action@v6
3042
with:
3143
context: .
3244
target: prod
45+
tags: thirdweb/engine:nightly-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
3346
platforms: ${{ matrix.platform }}
34-
push: true
47+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
3548
cache-from: type=gha,scope=${{ matrix.platform }}
3649
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
37-
tags: thirdweb/engine:nightly-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
38-
build-args: |
39-
ENGINE_VERSION=nightly
50+
build-args: ENGINE_VERSION=nightly
51+
52+
- name: Export digest
53+
run: |
54+
mkdir -p /tmp/digests
55+
digest="${{ steps.build.outputs.digest }}"
56+
touch "/tmp/digests/${digest#sha256:}"
4057
41-
merge-manifests:
58+
- name: Upload digest
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: digests-${{ env.PLATFORM_PAIR }}
62+
path: /tmp/digests/*
63+
if-no-files-found: error
64+
retention-days: 1
65+
66+
merge:
4267
needs: build
4368
runs-on: ubuntu-latest
4469
steps:
70+
- name: Download digests
71+
uses: actions/download-artifact@v4
72+
with:
73+
path: /tmp/digests
74+
pattern: digests-*
75+
merge-multiple: true
76+
77+
- name: Set up Docker Buildx
78+
uses: docker/setup-buildx-action@v3
79+
4580
- name: Login to DockerHub
46-
uses: docker/login-action@v1
81+
uses: docker/login-action@v3
4782
with:
4883
username: ${{ secrets.DOCKER_USERNAME }}
4984
password: ${{ secrets.DOCKER_PASSWORD }}
5085

51-
- name: Create and Push Multi-arch Manifest (nightly)
86+
- name: Create manifest list and push
87+
working-directory: /tmp/digests
88+
run: |
89+
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:nightly \
90+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
91+
92+
- name: Inspect image
5293
run: |
53-
docker manifest create thirdweb/engine:nightly \
54-
thirdweb/engine:nightly-amd64 \
55-
thirdweb/engine:nightly-arm64
56-
docker manifest push thirdweb/engine:nightly
94+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:nightly

.github/workflows/tagBasedImageBuild.yml

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,104 @@ on:
44
release:
55
types: [created] # This listens to release creation events
66

7+
env:
8+
REGISTRY_IMAGE: thirdweb/engine
9+
710
jobs:
8-
buildImageForNewTag:
9-
runs-on: ubuntu-latest
11+
build:
12+
runs-on: ${{ matrix.runner }}
1013
strategy:
1114
matrix:
12-
platform: [linux/amd64, linux/arm64]
15+
include:
16+
- platform: linux/amd64
17+
runner: ubuntu-latest
18+
- platform: linux/arm64
19+
runner: ubuntu-24.04-arm64
1320
env:
14-
LATEST_TAG: ${{ (github.event.release.target_commitish == 'main') && 'thirdweb/engine:latest' || '' }}
21+
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}
1522

1623
steps:
1724
- name: Checkout code
18-
uses: actions/checkout@v2
25+
uses: actions/checkout@v3
1926
with:
2027
ref: ${{ github.event.release.target_commitish }}
2128

29+
- name: Prepare
30+
run: |
31+
platform=${{ matrix.platform }}
32+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
33+
2234
- name: Set up Docker Buildx
2335
uses: docker/setup-buildx-action@v3
2436

2537
- name: Login to DockerHub
26-
uses: docker/login-action@v1
38+
uses: docker/login-action@v3
2739
with:
2840
username: ${{ secrets.DOCKER_USERNAME }}
2941
password: ${{ secrets.DOCKER_PASSWORD }}
3042

3143
- name: Build and Push Docker Image
32-
uses: docker/build-push-action@v2
44+
uses: docker/build-push-action@v6
3345
with:
3446
context: .
3547
target: prod
3648
platforms: ${{ matrix.platform }}
37-
push: true
49+
tags: |
50+
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
51+
${{ env.LATEST_TAG != '' && format('thirdweb/engine:latest-{0}', matrix.platform == 'linux/amd64' && 'amd64' || 'arm64') || '' }}
52+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
3853
cache-from: type=gha,scope=${{ matrix.platform }}
3954
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
40-
tags: |
41-
thirdweb/engine:${{ github.event.release.tag_name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
42-
${{ env.LATEST_TAG != '' && format('thirdweb/engine:latest-{0}', matrix.platform == 'linux/amd64' && 'amd64' || 'arm64') || '' }}
43-
build-args: |
44-
ENGINE_VERSION=${{ github.event.release.tag_name }}
55+
build-args: ENGINE_VERSION=${{ github.event.release.tag_name }}
56+
57+
- name: Export digest
58+
run: |
59+
mkdir -p /tmp/digests
60+
digest="${{ steps.build.outputs.digest }}"
61+
touch "/tmp/digests/${digest#sha256:}"
62+
63+
- name: Upload digest
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: digests-${{ env.PLATFORM_PAIR }}
67+
path: /tmp/digests/*
68+
if-no-files-found: error
69+
retention-days: 1
4570

4671
merge-manifests:
47-
needs: buildImageForNewTag
72+
needs: build
4873
runs-on: ubuntu-latest
4974
env:
50-
LATEST_TAG: ${{ (github.event.release.target_commitish == 'main') && 'thirdweb/engine:latest' || '' }}
75+
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}
5176
steps:
77+
- name: Download digests
78+
uses: actions/download-artifact@v4
79+
with:
80+
path: /tmp/digests
81+
pattern: digests-*
82+
merge-multiple: true
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@v3
86+
5287
- name: Login to DockerHub
53-
uses: docker/login-action@v1
88+
uses: docker/login-action@v3
5489
with:
5590
username: ${{ secrets.DOCKER_USERNAME }}
5691
password: ${{ secrets.DOCKER_PASSWORD }}
5792

5893
- name: Create and Push Multi-arch Manifest (release tag)
94+
working-directory: /tmp/digests
5995
run: |
60-
docker manifest create thirdweb/engine:${{ github.event.release.tag_name }} \
61-
thirdweb/engine:${{ github.event.release.tag_name }}-amd64 \
62-
thirdweb/engine:${{ github.event.release.tag_name }}-arm64
63-
docker manifest push thirdweb/engine:${{ github.event.release.tag_name }}
96+
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }} \
97+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
6498
65-
- name: Create and Push Latest Tag (if applicable)
99+
- name: Create and Push Multi-arch Manifest (latest tag) (if applicable)
66100
if: ${{ env.LATEST_TAG != '' }}
67101
run: |
68-
docker manifest create thirdweb/engine:latest \
69-
thirdweb/engine:latest-amd64 \
70-
thirdweb/engine:latest-arm64
71-
docker manifest push thirdweb/engine:latest
102+
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:latest \
103+
${{ env.REGISTRY_IMAGE }}@sha256:${{ steps.build.outputs.digest }}
104+
105+
- name: Inspect image
106+
run: |
107+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}

0 commit comments

Comments
 (0)