4
4
release :
5
5
types : [created] # This listens to release creation events
6
6
7
+ env :
8
+ REGISTRY_IMAGE : thirdweb/engine
9
+
7
10
jobs :
8
- buildImageForNewTag :
9
- runs-on : ubuntu-latest
11
+ build :
12
+ runs-on : ${{ matrix.runner }}
10
13
strategy :
11
14
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
13
20
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' || '' }}
15
22
16
23
steps :
17
24
- name : Checkout code
18
- uses : actions/checkout@v2
25
+ uses : actions/checkout@v3
19
26
with :
20
27
ref : ${{ github.event.release.target_commitish }}
21
28
29
+ - name : Prepare
30
+ run : |
31
+ platform=${{ matrix.platform }}
32
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
33
+
22
34
- name : Set up Docker Buildx
23
35
uses : docker/setup-buildx-action@v3
24
36
25
37
- name : Login to DockerHub
26
- uses : docker/login-action@v1
38
+ uses : docker/login-action@v3
27
39
with :
28
40
username : ${{ secrets.DOCKER_USERNAME }}
29
41
password : ${{ secrets.DOCKER_PASSWORD }}
30
42
31
43
- name : Build and Push Docker Image
32
- uses : docker/build-push-action@v2
44
+ uses : docker/build-push-action@v6
33
45
with :
34
46
context : .
35
47
target : prod
36
48
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
38
53
cache-from : type=gha,scope=${{ matrix.platform }}
39
54
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
45
70
46
71
merge-manifests :
47
- needs : buildImageForNewTag
72
+ needs : build
48
73
runs-on : ubuntu-latest
49
74
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' || '' }}
51
76
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
+
52
87
- name : Login to DockerHub
53
- uses : docker/login-action@v1
88
+ uses : docker/login-action@v3
54
89
with :
55
90
username : ${{ secrets.DOCKER_USERNAME }}
56
91
password : ${{ secrets.DOCKER_PASSWORD }}
57
92
58
93
- name : Create and Push Multi-arch Manifest (release tag)
94
+ working-directory : /tmp/digests
59
95
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 ' *)
64
98
65
- - name : Create and Push Latest Tag (if applicable)
99
+ - name : Create and Push Multi-arch Manifest (latest tag) (if applicable)
66
100
if : ${{ env.LATEST_TAG != '' }}
67
101
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