15
15
registry :
16
16
description : The registry to push container images to.
17
17
type : string
18
- required : true
18
+ required : false
19
+ default : ghcr.io
19
20
username :
20
21
description : The username for the registry.
21
22
type : string
@@ -69,28 +70,33 @@ jobs:
69
70
replace-with : " $1"
70
71
flags : " g"
71
72
72
- # This is the intended approach to multi-arch image and all the other checks scanning,
73
- # signing, etc only trigger from this.
74
- call-build-images :
75
- needs :
76
- - call-build-images-meta
77
- name : Multiarch container images to GHCR
78
- runs-on : ubuntu-latest
79
- environment : ${{ inputs.environment }}
73
+ # Taken from https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
74
+ # We split this out to make it easier to restart just one of them if it fails and do all in parallel
75
+ call-build-single-arch-container-images :
76
+ # Allow us to continue to create a manifest if we want
77
+ continue-on-error : true
80
78
permissions :
81
79
contents : read
82
80
packages : write
83
- outputs :
84
- production-digest : ${{ steps.build_push.outputs.digest }}
85
- debug-digest : ${{ steps.debug_build_push.outputs.digest }}
81
+ strategy :
82
+ fail-fast : false
83
+ matrix :
84
+ platform :
85
+ - amd64
86
+ - arm64
87
+ - arm/v7
88
+ target :
89
+ - production
90
+ - debug
91
+ name : ${{ matrix.platform }}/${{ matrix.target }} container image build
92
+ # Use GitHub Actions ARM hosted runners
93
+ runs-on : ${{ (contains(matrix.platform, 'arm') && 'ubuntu-22.04-arm') || 'ubuntu-latest' }}
86
94
steps :
87
- - name : Checkout code for modern style builds
95
+ - name : Checkout code
88
96
uses : actions/checkout@v4
89
97
with :
90
98
ref : ${{ inputs.ref }}
91
-
92
- - name : Set up QEMU
93
- uses : docker/setup-qemu-action@v3
99
+ token : ${{ secrets.token }}
94
100
95
101
- name : Set up Docker Buildx
96
102
uses : docker/setup-buildx-action@v3
@@ -99,37 +105,108 @@ jobs:
99
105
uses : docker/login-action@v3
100
106
with :
101
107
registry : ${{ inputs.registry }}
102
- username : ${{ inputs.username }}
108
+ username : ${{ github.actor }}
103
109
password : ${{ secrets.token }}
104
110
105
- - name : Extract metadata from Github
106
- id : meta
107
- uses : docker/metadata-action@v5
108
- with :
109
- images : ${{ inputs.registry }}/${{ inputs.image }}
110
- tags : |
111
- raw,${{ inputs.version }}
112
- raw,${{ needs.call-build-images-meta.outputs.major-version }}
113
- raw,latest
114
-
115
- - name : Build the production images
116
- id : build_push
111
+ - name : Build and push by digest the standard ${{ matrix.target }} image
112
+ id : build
117
113
uses : docker/build-push-action@v6
118
114
with :
115
+ # Use path context rather than Git context as we want local files
119
116
file : ./dockerfiles/Dockerfile
120
117
context : .
121
- tags : ${{ steps.meta.outputs.tags }}
122
- labels : ${{ steps.meta.outputs.labels }}
123
- platforms : linux/amd64, linux/arm64, linux/arm/v7, linux/s390x
124
- target : production
118
+ target : ${{ matrix.target }}
119
+ outputs : type=image,name=${{ inputs.registry }}/${{ inputs.image }},push-by-digest=true,name-canonical=true,push=true
120
+ platforms : linux/${{ matrix.platform }}
125
121
# Must be disabled to provide legacy format images from the registry
126
122
provenance : false
127
123
push : true
128
124
load : false
129
125
build-args : |
130
126
FLB_NIGHTLY_BUILD=${{ inputs.unstable }}
131
127
RELEASE_VERSION=${{ inputs.version }}
128
+ WAMR_BUILD_TARGET=${{ (contains(matrix.platform, 'arm/v7') && 'ARMV7') || '' }}
129
+
130
+ - name : Export ${{ matrix.target }} digest
131
+ run : |
132
+ mkdir -p /tmp/digests
133
+ digest="${{ steps.build.outputs.digest }}"
134
+ touch "/tmp/digests/${digest#sha256:}"
135
+ shell : bash
136
+
137
+ - name : Upload ${{ matrix.target }} digest
138
+ uses : actions/upload-artifact@v4
139
+ with :
140
+ name : ${{ matrix.target }}-digests-${{ (contains(matrix.platform, 'arm/v7') && 'arm-v7') || matrix.platform }}
141
+ path : /tmp/digests/*
142
+ if-no-files-found : error
143
+ retention-days : 1
144
+
145
+ # Take the digests and produce a multi-arch manifest from them.
146
+ call-build-container-image-manifests :
147
+ permissions :
148
+ contents : read
149
+ packages : write
150
+ name : Upload multi-arch container image manifests
151
+ runs-on : ubuntu-latest
152
+ needs :
153
+ - call-build-images-meta
154
+ - call-build-single-arch-container-images
155
+ outputs :
156
+ version : ${{ steps.meta.outputs.version }}
157
+ steps :
158
+ - name : Extract metadata from Github
159
+ id : meta
160
+ uses : docker/metadata-action@v5
161
+ with :
162
+ images : ${{ inputs.registry }}/${{ inputs.image }}
163
+ tags : |
164
+ raw,${{ inputs.version }}
165
+ raw,${{ needs.call-build-images-meta.outputs.major-version }}
166
+ raw,latest
167
+
168
+ - name : Download production digests
169
+ uses : actions/download-artifact@v4
170
+ with :
171
+ pattern : production-digests-*
172
+ path : /tmp/production-digests
173
+ merge-multiple : true
174
+
175
+ - name : Set up Docker Buildx
176
+ uses : docker/setup-buildx-action@v3
177
+
178
+ - name : Log in to the Container registry
179
+ uses : docker/login-action@v3
180
+ with :
181
+ registry : ${{ inputs.registry }}
182
+ username : ${{ github.actor }}
183
+ password : ${{ secrets.token }}
184
+
185
+ - name : Create production manifest
186
+ run : |
187
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
188
+ $(printf '${{ inputs.registry }}/${{ inputs.image }}@sha256:%s ' *)
189
+ shell : bash
190
+ working-directory : /tmp/production-digests
132
191
192
+ - name : Inspect image
193
+ run : |
194
+ docker buildx imagetools inspect ${{ inputs.registry }}/${{ inputs.image }}:${{ steps.meta.outputs.version }}
195
+ shell : bash
196
+
197
+ # Take the digests and produce a multi-arch manifest from them.
198
+ call-build-debug-container-image-manifests :
199
+ permissions :
200
+ contents : read
201
+ packages : write
202
+ name : Upload debug multi-arch container image manifests
203
+ runs-on : ubuntu-latest
204
+ needs :
205
+ - call-build-images-meta
206
+ - call-build-single-arch-container-images
207
+ outputs :
208
+ version : ${{ steps.debug-meta.outputs.version }}
209
+ steps :
133
210
- id : debug-meta
134
211
uses : docker/metadata-action@v5
135
212
with :
@@ -139,28 +216,39 @@ jobs:
139
216
raw,${{ needs.call-build-images-meta.outputs.major-version }}-debug
140
217
raw,latest-debug
141
218
142
- - name : Build the debug multi-arch images
143
- id : debug_build_push
144
- uses : docker/build-push-action@v6
219
+ - name : Download debug digests
220
+ uses : actions/download-artifact@v4
145
221
with :
146
- file : ./dockerfiles/Dockerfile
147
- context : .
148
- tags : ${{ steps.debug-meta.outputs.tags }}
149
- labels : ${{ steps.debug-meta.outputs.labels }}
150
- platforms : linux/amd64, linux/arm64, linux/arm/v7, linux/s390x
151
- # Must be disabled to provide legacy format images from the registry
152
- provenance : false
153
- target : debug
154
- push : true
155
- load : false
156
- build-args : |
157
- FLB_NIGHTLY_BUILD=${{ inputs.unstable }}
158
- RELEASE_VERSION=${{ inputs.version }}
222
+ pattern : debug-digests-*
223
+ path : /tmp/debug-digests
224
+ merge-multiple : true
225
+
226
+ - name : Set up Docker Buildx
227
+ uses : docker/setup-buildx-action@v3
228
+
229
+ - name : Log in to the Container registry
230
+ uses : docker/login-action@v3
231
+ with :
232
+ registry : ${{ inputs.registry }}
233
+ username : ${{ github.actor }}
234
+ password : ${{ secrets.token }}
235
+
236
+ - name : Create debug manifest
237
+ run : |
238
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
239
+ $(printf '${{ inputs.registry }}/${{ inputs.image }}@sha256:%s ' *)
240
+ shell : bash
241
+ working-directory : /tmp/debug-digests
242
+
243
+ - name : Inspect image
244
+ run : |
245
+ docker buildx imagetools inspect ${{ inputs.registry }}/${{ inputs.image }}:${{ steps.debug-meta.outputs.version }}
246
+ shell : bash
159
247
160
248
call-build-images-generate-schema :
161
249
needs :
162
250
- call-build-images-meta
163
- - call-build-images
251
+ - call-build-container-image-manifests
164
252
runs-on : ubuntu-latest
165
253
environment : ${{ inputs.environment }}
166
254
permissions :
@@ -190,7 +278,7 @@ jobs:
190
278
call-build-images-scan :
191
279
needs :
192
280
- call-build-images-meta
193
- - call-build-images
281
+ - call-build-container-image-manifests
194
282
name : Trivy + Dockle image scan
195
283
runs-on : ubuntu-latest
196
284
environment : ${{ inputs.environment }}
@@ -225,7 +313,8 @@ jobs:
225
313
call-build-images-sign :
226
314
needs :
227
315
- call-build-images-meta
228
- - call-build-images
316
+ - call-build-container-image-manifests
317
+ - call-build-debug-container-image-manifests
229
318
name : Deploy and sign multi-arch container image manifests
230
319
permissions :
231
320
contents : read
@@ -246,13 +335,13 @@ jobs:
246
335
#
247
336
# We use recursive signing on the manifest to cover all the images.
248
337
run : |
249
- cosign sign --recursive \
338
+ cosign sign --recursive --force \
250
339
-a "repo=${{ github.repository }}" \
251
340
-a "workflow=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
252
341
-a "ref=${{ github.sha }}" \
253
342
-a "release=${{ inputs.version }}" \
254
- "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-images .outputs.production-digest }}" \
255
- "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-images .outputs.debug-digest }}"
343
+ "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-container-image-manifests .outputs.version }}" \
344
+ "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-debug-container-image-manifests .outputs.version }}"
256
345
shell : bash
257
346
# Ensure we move on to key-based signing as well
258
347
continue-on-error : true
@@ -265,13 +354,13 @@ jobs:
265
354
# The key needs to cope with newlines
266
355
run : |
267
356
echo -e "${COSIGN_PRIVATE_KEY}" > /tmp/my_cosign.key
268
- cosign sign --key /tmp/my_cosign.key --recursive \
357
+ cosign sign --key /tmp/my_cosign.key --recursive --force \
269
358
-a "repo=${{ github.repository }}" \
270
359
-a "workflow=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
271
360
-a "ref=${{ github.sha }}" \
272
361
-a "release=${{ inputs.version }}" \
273
- "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-images .outputs.production-digest }}" \
274
- "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-images .outputs.debug-digest }}"
362
+ "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-container-image-manifests .outputs.version }}" \
363
+ "${{ inputs.registry }}/${{ inputs.image }}@${{ needs.call-build-debug-container-image-manifests .outputs.version }}"
275
364
rm -f /tmp/my_cosign.key
276
365
shell : bash
277
366
continue-on-error : true
0 commit comments