11name : Build-Test-Push
2+
23on :
34 schedule :
45 - cron : " 5 4 * * 3"
1314
1415jobs :
1516 gather-versions :
16- runs-on : ubuntu-22 .04
17+ runs-on : ubuntu-24 .04
1718 outputs :
1819 versions : ${{ steps.ruby-versions.outputs.versions }}
1920 metadata : ${{ steps.ruby-versions.outputs.metadata }}
2021 steps :
2122 - uses : moritzheiber/ruby-versions-action@v1
2223 name : Fetch latest Ruby versions
2324 id : ruby-versions
25+
2426 build-test-push :
25- runs-on : ubuntu-22.04
2627 needs : ["gather-versions"]
2728 strategy :
2829 matrix :
2930 version : ${{ fromJSON(needs.gather-versions.outputs.versions) }}
30- image : ["slim", "ubuntu-22.04", "ubuntu-24.04"]
31+ image : [slim, ubuntu-22.04, ubuntu-24.04]
32+ platform : [amd64, arm64]
3133 include : ${{ fromJSON(needs.gather-versions.outputs.metadata) }}
34+ runs-on : ${{ matrix.platform == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
3235 steps :
3336 - name : Set image_name
3437 id : context
3538 run : |
3639 if [[ "${{ matrix.image }}" == "slim" ]] ; then
3740 echo "image_name=ruby:${{ matrix.version }}-slim" >> ${GITHUB_OUTPUT}
3841 elif [[ "${{ matrix.image }}" == "ubuntu-22.04" ]] ; then
39- echo "image_name=ubuntu:20.04" >> ${GITHUB_OUTPUT}
40- elif [[ "${{ matrix.image }}" == "ubuntu-24.04" ]] ; then
4142 echo "image_name=ubuntu:22.04" >> ${GITHUB_OUTPUT}
43+ elif [[ "${{ matrix.image }}" == "ubuntu-24.04" ]] ; then
44+ echo "image_name=ubuntu:24.04" >> ${GITHUB_OUTPUT}
4245 fi
4346
4447 if [[ "${{ startsWith(matrix.version, '3.2') }}" == "true" ]] ; then
@@ -51,21 +54,67 @@ jobs:
5154 registry : ghcr.io
5255 username : ${{ github.actor }}
5356 password : ${{ secrets.GITHUB_TOKEN }}
54- - uses : docker/setup-qemu-action@v3
5557 - uses : docker/setup-buildx-action@v3
5658 with :
5759 driver-opts : |
58- image=moby/buildkit:v0.10.6
60+ image=moby/buildkit:v0.19.0
5961 - uses : docker/build-push-action@v6
6062 name : Build
63+ id : build
6164 with :
62- platforms : linux/amd64,linux/arm64
65+ platforms : linux/${{ matrix.platform }}
6366 push : ${{ github.ref == 'refs/heads/main' }}
6467 cache-from : type=gha
65- cache-to : type=gha
68+ cache-to : type=gha,mode=max
6669 build-args : |
6770 RUBY_VERSION=${{ matrix.version }}
6871 RUBY_CHECKSUM=${{ matrix.checksum }}
6972 IMAGE_NAME=${{ steps.context.outputs.image_name }}
7073 ADDITIONAL_FLAGS=${{ steps.context.outputs.flags }}
71- tags : " ghcr.io/moritzheiber/ruby-jemalloc:${{ matrix.version }}-${{ matrix.image }}"
74+ provenance : false
75+ outputs : |
76+ type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,push=${{ github.ref == 'refs/heads/main' }}
77+ - name : Export digest
78+ if : github.ref == 'refs/heads/main'
79+ run : |
80+ mkdir -p /tmp/digests/${{ matrix.version }}-${{ matrix.image }}
81+ digest="${{ steps.build.outputs.digest }}"
82+ touch "/tmp/digests/${{ matrix.version }}-${{ matrix.image }}/${digest#sha256:}"
83+ - name : Upload digest
84+ if : github.ref == 'refs/heads/main'
85+ uses : actions/upload-artifact@v3
86+ with :
87+ name : digests-${{ matrix.version }}-${{ matrix.image }}
88+ path : /tmp/digests/${{ matrix.version }}-${{ matrix.image }}/*
89+ if-no-files-found : error
90+ retention-days : 1
91+
92+ merge-manifests :
93+ needs : ["build-test-push", "gather-versions"]
94+ if : github.ref == 'refs/heads/main'
95+ runs-on : ubuntu-24.04
96+ strategy :
97+ matrix :
98+ version : ${{ fromJSON(needs.gather-versions.outputs.versions) }}
99+ image : [slim, ubuntu-22.04, ubuntu-24.04]
100+ steps :
101+ - name : Login to GHCR
102+ uses : docker/login-action@v3
103+ with :
104+ registry : ghcr.io
105+ username : ${{ github.actor }}
106+ password : ${{ secrets.GITHUB_TOKEN }}
107+ - uses : docker/setup-buildx-action@v3
108+ with :
109+ driver-opts : |
110+ image=moby/buildkit:v0.19.0
111+ - name : Download digests
112+ uses : actions/download-artifact@v3
113+ with :
114+ name : digests-${{ matrix.version }}-${{ matrix.image }}
115+ path : /tmp/digests/${{ matrix.version }}-${{ matrix.image }}
116+ - name : Create and push manifest
117+ working-directory : /tmp/digests/${{ matrix.version }}-${{ matrix.image }}
118+ run : |
119+ docker buildx imagetools create -t ghcr.io/${{ github.repository }}:${{ matrix.version }}-${{ matrix.image }} \
120+ $(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)
0 commit comments