-
Notifications
You must be signed in to change notification settings - Fork 30
81 lines (80 loc) · 3.07 KB
/
publish-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Publish docker images to GHCR
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
cancel-in-progress: true
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * 3" # At 03:00 on Wednesday # https://crontab.guru/#0_3_*_*_3
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- aarch64-linux-gnu
- aarch64-linux-musl
- arm-linux-gnu
- arm-linux-musl
- arm64-darwin
- jruby
- x64-mingw-ucrt
- x64-mingw32
- x86-linux-gnu
- x86-linux-musl
- x86-mingw32
- x86_64-darwin
- x86_64-linux-gnu
- x86_64-linux-musl
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use cache from primary pipeline
uses: actions/cache@v4
with:
path: tmp/build-cache
key: ${{runner.os}}-${{matrix.platform}}-buildx-${{github.sha}}
restore-keys: |
${{runner.os}}-${{matrix.platform}}-buildx
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- name: Generate docker image names
id: rcd_config
run: |
bundle exec ruby -e ' \
require "rake_compiler_dock"; \
print "image_name="; \
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \
print "snapshot_name="; \
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)); \
if %q(${{matrix.platform}}).end_with?("-gnu"); \
print "generic_linux_snapshot_name="; \
puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)).chomp("-gnu"); \
end \
' | tee -a $GITHUB_OUTPUT
- name: Build docker image
env:
RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new --load
run: |
docker buildx create --driver docker-container --use
bundle exec rake build:${{matrix.platform}}
# move build cache and remove outdated layers
rm -rf tmp/build-cache
mv tmp/build-cache-new tmp/build-cache
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Push the docker image
run: |
docker images
docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.snapshot_name}}
docker push ${{steps.rcd_config.outputs.snapshot_name}}
- name: Push a generic linux image
if: ${{ steps.rcd_config.outputs.generic_linux_snapshot_name }}
run: |
docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.generic_linux_snapshot_name}}
docker push ${{steps.rcd_config.outputs.generic_linux_snapshot_name}}