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
@@ -188,16 +167,30 @@ jobs:
188
167
strategy :
189
168
fail-fast : false
190
169
matrix :
191
- target-stage :
170
+ target :
192
171
- ' '
193
172
- rootless
194
173
steps :
195
174
-
196
175
name : Checkout
197
176
uses : actions/checkout@v4
177
+ with :
178
+ fetch-depth : 0
198
179
-
199
- name : Expose GitHub Runtime
200
- uses : crazy-max/ghaction-github-runtime@v3
180
+ name : Prepare
181
+ run : |
182
+ if [ -n "${{ matrix.target }}" ]; then
183
+ echo "TAG_SUFFIX=-${{ matrix.target }}" >> $GITHUB_ENV
184
+ fi
185
+ if [[ $GITHUB_REF == refs/tags/v* ]]; then
186
+ if [[ "${GITHUB_REF#refs/tags/}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
187
+ if [ -n "${{ matrix.target }}" ]; then
188
+ echo "TAG_LATEST=${{ matrix.target }}" >> $GITHUB_ENV
189
+ else
190
+ echo "TAG_LATEST=latest" >> $GITHUB_ENV
191
+ fi
192
+ fi
193
+ fi
201
194
-
202
195
name : Set up QEMU
203
196
uses : docker/setup-qemu-action@v3
@@ -208,23 +201,64 @@ jobs:
208
201
version : ${{ env.SETUP_BUILDX_VERSION }}
209
202
driver-opts : image=${{ env.SETUP_BUILDKIT_IMAGE }}
210
203
buildkitd-flags : --debug
204
+ -
205
+ name : Docker meta
206
+ id : meta
207
+ uses : docker/metadata-action@v5
208
+ with :
209
+ images : |
210
+ ${{ env.IMAGE_NAME }}
211
+ # versioning strategy
212
+ # # push semver tag v0.24.0
213
+ # ## moby/buildkit:v0.24.0
214
+ # ## moby/buildkit:latest
215
+ # ## moby/buildkit:v0.24.0-rootless
216
+ # ## moby/buildkit:rootless
217
+ # # push semver prerelease tag v0.24.0-rc1
218
+ # ## moby/buildkit:v0.24.0-rc1
219
+ # ## moby/buildkit:v0.24.0-rc1-rootless
220
+ # # push on master
221
+ # ## moby/buildkit:master
222
+ # # scheduled event on master
223
+ # ## moby/buildkit:nightly
224
+ tags : |
225
+ type=schedule,pattern=nightly,suffix=${{ env.TAG_SUFFIX }}
226
+ type=ref,event=branch,suffix=${{ env.TAG_SUFFIX }}
227
+ type=ref,event=pr,suffix=${{ env.TAG_SUFFIX }}
228
+ type=semver,pattern={{raw}},suffix=${{ env.TAG_SUFFIX }}
229
+ type=raw,value=${{ env.TAG_LATEST }}
230
+ flavor : |
231
+ latest=false
232
+ annotations : |
233
+ org.opencontainers.image.title=BuildKit
234
+ org.opencontainers.image.vendor=Moby
235
+ bake-target : meta-helper
211
236
-
212
237
name : Login to DockerHub
213
- if : needs.prepare.outputs.push == 'push'
238
+ if : ${{ github.repository == 'moby/buildkit' && (github.event_name == 'schedule' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
214
239
uses : docker/login-action@v3
215
240
with :
216
241
username : ${{ secrets.DOCKERHUB_USERNAME }}
217
242
password : ${{ secrets.DOCKERHUB_TOKEN }}
218
243
-
219
- name : Build ${{ needs.prepare.outputs.tag }}
220
- run : |
221
- ./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
244
+ name : Build
245
+ uses : docker/bake-action@v6
246
+ with :
247
+ source : .
248
+ files : |
249
+ ./docker-bake.hcl
250
+ ${{ steps.meta.outputs.bake-file-tags }}
251
+ ${{ steps.meta.outputs.bake-file-annotations }}
252
+ targets : image-cross
253
+ push : ${{ github.repository == 'moby/buildkit' && (github.event_name == 'schedule' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
254
+ provenance : mode=max
255
+ sbom : true
256
+ set : |
257
+ *.cache-from=type=gha,scope=image${{ matrix.target }}
258
+ *.cache-to=type=gha,scope=image${{ matrix.target }}
259
+ *.no-cache-filter=${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && 'buildkit-export,gobuild-base,rootless' || '' }}
222
260
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 }}
261
+ IMAGE_TARGET : ${{ matrix.target }}
228
262
229
263
scout :
230
264
runs-on : ubuntu-24.04
0 commit comments