Skip to content

Commit 4ad169b

Browse files
committed
CI: Update publish job to push multiplatform images
1 parent 8fdd7cd commit 4ad169b

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

.github/workflows/publish-images.yml

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,52 +31,45 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/checkout@v4
34-
- name: Use cache from primary pipeline
35-
uses: actions/cache@v4
34+
- name: Use X64 cache from primary pipeline
35+
uses: actions/cache/restore@v4
3636
with:
37-
path: tmp/build-cache
38-
key: ${{runner.os}}-${{matrix.platform}}-buildx-${{github.sha}}
39-
restore-keys: |
40-
${{runner.os}}-${{matrix.platform}}-buildx
37+
path: tmp/build-cache-X64
38+
key: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx-${{ github.sha }}
39+
restore-keys: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx
40+
- name: Use ARM64 cache from primary pipeline
41+
uses: actions/cache/restore@v4
42+
with:
43+
path: tmp/build-cache-ARM64
44+
key: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx-${{ github.sha }}
45+
restore-keys: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx
46+
fail-on-cache-miss: true
4147
- uses: ruby/setup-ruby@v1
4248
with:
4349
ruby-version: "3.3"
4450
bundler-cache: true
51+
- uses: docker/login-action@v3
52+
with:
53+
registry: ghcr.io
54+
username: ${{github.actor}}
55+
password: ${{secrets.GITHUB_TOKEN}}
4556
- name: Generate docker image names
4657
id: rcd_config
4758
run: |
4859
bundle exec ruby -e ' \
4960
require "rake_compiler_dock"; \
50-
print "image_name="; \
61+
print "image_name_opt=-t "; \
5162
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \
52-
print "snapshot_name="; \
63+
print "snapshot_name_opt=-t "; \
5364
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)); \
5465
if %q(${{matrix.platform}}).end_with?("-gnu"); \
55-
print "generic_linux_snapshot_name="; \
66+
print "generic_linux_snapshot_name_opt=-t "; \
5667
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)).chomp("-gnu"); \
5768
end \
5869
' | tee -a $GITHUB_OUTPUT
5970
- name: Build docker image
6071
env:
61-
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new
72+
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache-X64 --cache-from=type=local,src=tmp/build-cache-ARM64 --cache-to=type=local,dest=tmp/build-cache-new ${{steps.rcd_config.outputs.snapshot_name_opt}} ${{steps.rcd_config.outputs.generic_linux_snapshot_name_opt}}
6273
run: |
6374
docker buildx create --driver docker-container --use
64-
bundle exec rake build:x86:${{matrix.platform}}
65-
# move build cache and remove outdated layers
66-
rm -rf tmp/build-cache
67-
mv tmp/build-cache-new tmp/build-cache
68-
- uses: docker/login-action@v3
69-
with:
70-
registry: ghcr.io
71-
username: ${{github.actor}}
72-
password: ${{secrets.GITHUB_TOKEN}}
73-
- name: Push the docker image
74-
run: |
75-
docker images
76-
docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.snapshot_name}}
77-
docker push ${{steps.rcd_config.outputs.snapshot_name}}
78-
- name: Push a generic linux image
79-
if: ${{ steps.rcd_config.outputs.generic_linux_snapshot_name }}
80-
run: |
81-
docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.generic_linux_snapshot_name}}
82-
docker push ${{steps.rcd_config.outputs.generic_linux_snapshot_name}}
75+
bundle exec rake release:${{matrix.platform}}

Rakefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,23 @@ task :update_lists do
174174
end
175175

176176
namespace :release do
177-
desc "Push all docker images on #{host_platforms.map(&:first).join(",")}"
178-
task :images => "build:all" do
177+
host_pl = host_platforms.map(&:first).join(",")
178+
179+
desc "Push image for JRuby on #{host_pl}"
180+
task :jruby => ["build:x86:jruby", "build:arm:jruby"] do
179181
build_jruby_images(host_platforms, output: 'push')
180-
build_mri_images(platforms, host_platforms, output: 'push')
182+
end
183+
184+
desc "Push all docker images on #{host_pl}"
185+
multitask :images => :jruby
186+
187+
platforms.each do |platform, target|
188+
desc "Push image for platform #{platform} on #{host_pl}"
189+
task platform => ["build:x86:#{platform}", "build:arm:#{platform}"] do
190+
build_mri_images([platform], host_platforms, output: 'push')
191+
end
192+
193+
desc "Push all docker images on #{host_pl}"
194+
multitask :images => platform
181195
end
182196
end

0 commit comments

Comments
 (0)