Skip to content

Commit 6371091

Browse files
committed
CI: Change the release workflow the same way as the publish workflow
1 parent 3f7bbef commit 6371091

File tree

2 files changed

+79
-9
lines changed

2 files changed

+79
-9
lines changed

.github/workflows/publish-images.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,14 @@ jobs:
112112
run: |
113113
bundle exec ruby -e ' \
114114
require "rake_compiler_dock"; \
115-
print "image_name_opt=-t "; \
116-
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \
117115
print "snapshot_name_opt=-t "; \
118116
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)); \
119117
if %q(${{matrix.platform}}).end_with?("-gnu"); \
120118
print "generic_linux_snapshot_name_opt=-t "; \
121119
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)).chomp("-gnu"); \
122120
end \
123121
' | tee -a $GITHUB_OUTPUT
124-
- name: Build docker image
122+
- name: Use cache and push docker image
125123
env:
126124
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}}
127125
run: |

.github/workflows/release-images.yml

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,57 @@ on:
1616
jobs:
1717
build:
1818
name: "build ${{ inputs.tag }} ${{ matrix.platform }}"
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os:
23+
- ubuntu-latest
24+
- ubuntu-24.04-arm
25+
platform:
26+
- aarch64-linux-gnu
27+
- aarch64-linux-musl
28+
- aarch64-mingw-ucrt
29+
- arm-linux-gnu
30+
- arm-linux-musl
31+
- arm64-darwin
32+
- jruby
33+
- x64-mingw-ucrt
34+
- x64-mingw32
35+
- x86-linux-gnu
36+
- x86-linux-musl
37+
- x86-mingw32
38+
- x86_64-darwin
39+
- x86_64-linux-gnu
40+
- x86_64-linux-musl
41+
runs-on: ${{ matrix.os }}
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: ruby/setup-ruby@v1
45+
with:
46+
ruby-version: "3.3"
47+
bundler-cache: true
48+
49+
- name: Fetch docker buildx layer cache
50+
uses: actions/cache@v4
51+
with:
52+
path: tmp/build-cache-${{ runner.arch }}
53+
key: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildx-${{ github.sha }}
54+
restore-keys: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildx
55+
enableCrossOsArchive: true
56+
- name: Change docker to a cache-able driver
57+
run: |
58+
docker buildx create --driver docker-container --use
59+
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
60+
- name: Show docker images
61+
run: docker images
62+
- name: Update and prune docker buildx layer cache
63+
run: |
64+
rm -rf tmp/build-cache-${{ runner.arch }}
65+
mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}
66+
67+
push:
68+
needs: build
69+
name: "push ${{ inputs.tag }} ${{ matrix.platform }}"
1970
strategy:
2071
fail-fast: false
2172
matrix:
@@ -40,20 +91,41 @@ jobs:
4091
- uses: actions/checkout@v4
4192
with:
4293
ref: ${{ inputs.tag }}
43-
- name: Use cache from primary pipeline
44-
uses: actions/cache@v4
94+
- name: Use X64 cache from primary pipeline
95+
uses: actions/cache/restore@v4
96+
with:
97+
path: tmp/build-cache-X64
98+
key: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx-${{ github.sha }}
99+
restore-keys: ${{ runner.os }}-on-X64-${{ matrix.platform }}-buildx
100+
enableCrossOsArchive: true
101+
- name: Use ARM64 cache from primary pipeline
102+
uses: actions/cache/restore@v4
45103
with:
46-
path: tmp/build-cache
47-
key: ${{runner.os}}-${{matrix.platform}}-buildx-${{github.sha}}
48-
restore-keys: |
49-
${{runner.os}}-${{matrix.platform}}-buildx
104+
path: tmp/build-cache-ARM64
105+
key: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx-${{ github.sha }}
106+
restore-keys: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-buildx
107+
enableCrossOsArchive: true
108+
fail-on-cache-miss: true
50109
- uses: ruby/setup-ruby@v1
51110
with:
52111
ruby-version: "3.3"
53112
bundler-cache: true
54113
- name: Generate docker image names
55114
id: rcd_config
56115
run: |
116+
bundle exec ruby -e ' \
117+
require "rake_compiler_dock"; \
118+
print "image_name_opt=-t "; \
119+
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \
120+
print "snapshot_name_opt=-t "; \
121+
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)); \
122+
if %q(${{matrix.platform}}).end_with?("-gnu"); \
123+
print "generic_linux_snapshot_name_opt=-t "; \
124+
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)).chomp("-gnu"); \
125+
end \
126+
' | tee -a $GITHUB_OUTPUT
127+
128+
57129
bundle exec ruby -e ' \
58130
require "rake_compiler_dock"; \
59131
print "image_name="; \

0 commit comments

Comments
 (0)