3030 SETUP_BUILDKIT_IMAGE : " moby/buildkit:latest"
3131 SCOUT_VERSION : " 1.13.0"
3232 IMAGE_NAME : " moby/buildkit"
33- PLATFORMS : " linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64"
3433 DESTDIR : " ./bin"
3534
3635jobs :
3736 prepare :
3837 runs-on : ubuntu-24.04
3938 outputs :
40- tag : ${{ steps.prep.outputs.tag }}
41- push : ${{ steps.prep.outputs.push }}
42- platforms : ${{ steps.prep.outputs.platforms }}
39+ platforms-includes : ${{ steps.platforms.outputs.matrix }}
4340 steps :
4441 -
4542 name : Checkout
4643 uses : actions/checkout@v5
4744 -
48- name : Prepare
49- id : prep
50- 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- platforms=$(docker buildx bake release --print | jq -cr '.target."release".platforms')
71- echo "platforms=$platforms" >>${GITHUB_OUTPUT}
45+ name : Platforms matrix
46+ id : platforms
47+ uses : docker/bake-action/subaction/matrix@v6
48+ with :
49+ target : release
50+ fields : platforms
7251
7352 binaries :
7453 runs-on : ubuntu-24.04
@@ -77,12 +56,12 @@ jobs:
7756 strategy :
7857 fail-fast : false
7958 matrix :
80- platform : ${{ fromJson(needs.prepare.outputs.platforms) }}
59+ include : ${{ fromJson(needs.prepare.outputs.platforms-includes ) }}
8160 steps :
8261 -
8362 name : Prepare
8463 run : |
85- platform=${{ matrix.platform }}
64+ platform=${{ matrix.platforms }}
8665 echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
8766 -
8867 name : Checkout
10887 make release
10988 env :
11089 RELEASE : ${{ startsWith(github.ref, 'refs/tags/v') }}
111- PLATFORMS : ${{ matrix.platform }}
90+ PLATFORMS : ${{ matrix.platforms }}
11291 CACHE_FROM : type=gha,scope=binaries-${{ env.PLATFORM_PAIR }}
11392 CACHE_TO : type=gha,scope=binaries-${{ env.PLATFORM_PAIR }}
11493 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -183,21 +162,29 @@ jobs:
183162 image :
184163 runs-on : ubuntu-24.04
185164 needs :
186- - prepare
187165 - test
188166 strategy :
189167 fail-fast : false
190168 matrix :
191- target-stage :
169+ target :
192170 - ' '
193171 - rootless
194172 steps :
195173 -
196- name : Checkout
197- uses : actions/checkout@v5
198- -
199- name : Expose GitHub Runtime
200- uses : crazy-max/ghaction-github-runtime@v3
174+ name : Prepare
175+ run : |
176+ if [ -n "${{ matrix.target }}" ]; then
177+ echo "TAG_SUFFIX=-${{ matrix.target }}" >> $GITHUB_ENV
178+ fi
179+ if [[ $GITHUB_REF == refs/tags/v* ]]; then
180+ if [[ "${GITHUB_REF#refs/tags/}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
181+ if [ -n "${{ matrix.target }}" ]; then
182+ echo "TAG_LATEST=${{ matrix.target }}" >> $GITHUB_ENV
183+ else
184+ echo "TAG_LATEST=latest" >> $GITHUB_ENV
185+ fi
186+ fi
187+ fi
201188 -
202189 name : Set up QEMU
203190 uses : docker/setup-qemu-action@v3
@@ -208,23 +195,67 @@ jobs:
208195 version : ${{ env.SETUP_BUILDX_VERSION }}
209196 driver-opts : image=${{ env.SETUP_BUILDKIT_IMAGE }}
210197 buildkitd-flags : --debug
198+ -
199+ name : Docker meta
200+ id : meta
201+ uses : docker/metadata-action@v5
202+ with :
203+ images : |
204+ ${{ env.IMAGE_NAME }}
205+ # versioning strategy
206+ # # push semver tag v0.24.0
207+ # ## moby/buildkit:v0.24.0
208+ # ## moby/buildkit:latest
209+ # ## moby/buildkit:v0.24.0-rootless
210+ # ## moby/buildkit:rootless
211+ # # push semver prerelease tag v0.24.0-rc1
212+ # ## moby/buildkit:v0.24.0-rc1
213+ # ## moby/buildkit:v0.24.0-rc1-rootless
214+ # # push on master
215+ # ## moby/buildkit:master
216+ # ## moby/buildkit:master-rootless
217+ # # scheduled event on master
218+ # ## moby/buildkit:nightly
219+ # ## moby/buildkit:nightly-rootless
220+ tags : |
221+ type=schedule,pattern=nightly,suffix=${{ env.TAG_SUFFIX }}
222+ type=ref,event=branch,suffix=${{ env.TAG_SUFFIX }}
223+ type=ref,event=pr,suffix=${{ env.TAG_SUFFIX }}
224+ type=semver,pattern={{raw}},suffix=${{ env.TAG_SUFFIX }}
225+ type=raw,value=${{ env.TAG_LATEST }}
226+ flavor : |
227+ latest=false
228+ annotations : |
229+ org.opencontainers.image.title=BuildKit
230+ org.opencontainers.image.vendor=Moby
231+ bake-target : meta-helper
211232 -
212233 name : Login to DockerHub
213- if : needs.prepare.outputs.push == 'push'
234+ if : ${{ github.repository == 'moby/buildkit' && (github.event_name == 'schedule' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
214235 uses : docker/login-action@v3
215236 with :
216237 username : ${{ secrets.DOCKERHUB_USERNAME }}
217238 password : ${{ secrets.DOCKERHUB_TOKEN }}
218239 -
219- name : Build ${{ needs.prepare.outputs.tag }}
220- run : |
221- ./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
240+ name : Build
241+ uses : docker/bake-action@v6
242+ with :
243+ # FIXME: remove context once git context with query string implemented in actions-toolkit
244+ source : ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}
245+ files : |
246+ ./docker-bake.hcl
247+ cwd://${{ steps.meta.outputs.bake-file-tags }}
248+ cwd://${{ steps.meta.outputs.bake-file-annotations }}
249+ targets : image-cross
250+ push : ${{ github.repository == 'moby/buildkit' && (github.event_name == 'schedule' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
251+ provenance : mode=max,version=v1
252+ sbom : true
253+ set : |
254+ *.cache-from=type=gha,scope=image${{ matrix.target }}
255+ *.cache-to=type=gha,scope=image${{ matrix.target }}
256+ *.no-cache-filter=${{ (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && 'buildkit-export-alpine,buildkit-export-ubuntu,gobuild-base,rootless' || '' }}
222257 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 }}
258+ IMAGE_TARGET : ${{ matrix.target }}
228259
229260 scout :
230261 runs-on : ubuntu-24.04
@@ -276,7 +307,6 @@ jobs:
276307 # required to create GitHub release
277308 contents : write
278309 needs :
279- - prepare
280310 - test
281311 - binaries
282312 - image
@@ -301,4 +331,3 @@ jobs:
301331 with :
302332 draft : true
303333 files : ${{ env.DESTDIR }}/*
304- name : ${{ needs.prepare.outputs.tag }}
0 commit comments