37
37
prepare :
38
38
runs-on : ubuntu-24.04
39
39
outputs :
40
- tag : ${{ steps.prep.outputs.tag }}
41
- push : ${{ steps.prep.outputs.push }}
42
40
platforms : ${{ steps.prep.outputs.platforms }}
43
41
steps :
44
42
-
48
46
name : Prepare
49
47
id : prep
50
48
run : |
51
- TAG=pr
52
- PUSH=false
53
- if [ "${{ github.event_name }}" = "schedule" ]; then
54
- TAG=nightly
55
- PUSH=push
56
- elif [[ $GITHUB_REF == refs/tags/v* ]]; then
57
- TAG=${GITHUB_REF#refs/tags/}
58
- PUSH=push
59
- elif [[ $GITHUB_REF == refs/heads/* ]]; then
60
- TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
61
- if [ $GITHUB_REF = "refs/heads/${{ github.event.repository.default_branch }}" ]; then
62
- PUSH=push
63
- fi
64
- fi
65
- if [ "$GITHUB_REPOSITORY" != "moby/buildkit" ]; then
66
- PUSH=false
67
- fi
68
- echo "tag=${TAG}" >>${GITHUB_OUTPUT}
69
- echo "push=${PUSH}" >>${GITHUB_OUTPUT}
70
49
platforms=$(docker buildx bake release --print | jq -cr '.target."release".platforms')
71
50
echo "platforms=$platforms" >>${GITHUB_OUTPUT}
72
51
@@ -183,21 +162,34 @@ jobs:
183
162
image :
184
163
runs-on : ubuntu-24.04
185
164
needs :
186
- - prepare
187
165
- test
188
166
strategy :
189
167
fail-fast : false
190
168
matrix :
191
- target-stage :
169
+ target :
192
170
- ' '
193
171
- rootless
194
172
steps :
195
173
-
196
174
name : Checkout
197
175
uses : actions/checkout@v5
176
+ with :
177
+ fetch-depth : 0
198
178
-
199
- name : Expose GitHub Runtime
200
- uses : crazy-max/ghaction-github-runtime@v3
179
+ name : Prepare
180
+ run : |
181
+ if [ -n "${{ matrix.target }}" ]; then
182
+ echo "TAG_SUFFIX=-${{ matrix.target }}" >> $GITHUB_ENV
183
+ fi
184
+ if [[ $GITHUB_REF == refs/tags/v* ]]; then
185
+ if [[ "${GITHUB_REF#refs/tags/}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
186
+ if [ -n "${{ matrix.target }}" ]; then
187
+ echo "TAG_LATEST=${{ matrix.target }}" >> $GITHUB_ENV
188
+ else
189
+ echo "TAG_LATEST=latest" >> $GITHUB_ENV
190
+ fi
191
+ fi
192
+ fi
201
193
-
202
194
name : Set up QEMU
203
195
uses : docker/setup-qemu-action@v3
@@ -208,23 +200,66 @@ jobs:
208
200
version : ${{ env.SETUP_BUILDX_VERSION }}
209
201
driver-opts : image=${{ env.SETUP_BUILDKIT_IMAGE }}
210
202
buildkitd-flags : --debug
203
+ -
204
+ name : Docker meta
205
+ id : meta
206
+ uses : docker/metadata-action@v5
207
+ with :
208
+ images : |
209
+ ${{ env.IMAGE_NAME }}
210
+ # versioning strategy
211
+ # # push semver tag v0.24.0
212
+ # ## moby/buildkit:v0.24.0
213
+ # ## moby/buildkit:latest
214
+ # ## moby/buildkit:v0.24.0-rootless
215
+ # ## moby/buildkit:rootless
216
+ # # push semver prerelease tag v0.24.0-rc1
217
+ # ## moby/buildkit:v0.24.0-rc1
218
+ # ## moby/buildkit:v0.24.0-rc1-rootless
219
+ # # push on master
220
+ # ## moby/buildkit:master
221
+ # ## moby/buildkit:master-rootless
222
+ # # scheduled event on master
223
+ # ## moby/buildkit:nightly
224
+ # ## moby/buildkit:nightly-rootless
225
+ tags : |
226
+ type=schedule,pattern=nightly,suffix=${{ env.TAG_SUFFIX }}
227
+ type=ref,event=branch,suffix=${{ env.TAG_SUFFIX }}
228
+ type=ref,event=pr,suffix=${{ env.TAG_SUFFIX }}
229
+ type=semver,pattern={{raw}},suffix=${{ env.TAG_SUFFIX }}
230
+ type=raw,value=${{ env.TAG_LATEST }}
231
+ flavor : |
232
+ latest=false
233
+ annotations : |
234
+ org.opencontainers.image.title=BuildKit
235
+ org.opencontainers.image.vendor=Moby
236
+ bake-target : meta-helper
211
237
-
212
238
name : Login to DockerHub
213
- if : needs.prepare.outputs.push == 'push'
239
+ if : ${{ github.repository == 'moby/buildkit' && (github.event_name == 'schedule' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
214
240
uses : docker/login-action@v3
215
241
with :
216
242
username : ${{ secrets.DOCKERHUB_USERNAME }}
217
243
password : ${{ secrets.DOCKERHUB_TOKEN }}
218
244
-
219
- name : Build ${{ needs.prepare.outputs.tag }}
220
- run : |
221
- ./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
245
+ name : Build
246
+ uses : docker/bake-action@v6
247
+ with :
248
+ source : .
249
+ files : |
250
+ ./docker-bake.hcl
251
+ ${{ steps.meta.outputs.bake-file-tags }}
252
+ ${{ steps.meta.outputs.bake-file-annotations }}
253
+ targets : image-cross
254
+ push : ${{ github.repository == 'moby/buildkit' && (github.event_name == 'schedule' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
255
+ provenance : mode=max
256
+ sbom : true
257
+ set : |
258
+ *.cache-from=type=gha,scope=image${{ matrix.target }}
259
+ *.cache-to=type=gha,scope=image${{ matrix.target }}
260
+ *.no-cache-filter=${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && 'buildkit-export,gobuild-base,rootless' || '' }}
222
261
env :
223
- RELEASE : ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
224
- TARGET : ${{ matrix.target-stage }}
225
- CACHE_FROM : type=gha,scope=image${{ matrix.target-stage }}
226
- CACHE_TO : type=gha,scope=image${{ matrix.target-stage }}
227
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
262
+ IMAGE_TARGET : ${{ matrix.target }}
228
263
229
264
scout :
230
265
runs-on : ubuntu-24.04
0 commit comments