-
Notifications
You must be signed in to change notification settings - Fork 38
202 lines (172 loc) · 6.74 KB
/
Copy pathbuild.yml
File metadata and controls
202 lines (172 loc) · 6.74 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Build Docker image with multi-arch
on:
schedule:
- cron: '15 */8 * * *'
repository_dispatch:
types: [build]
workflow_dispatch:
inputs:
ruby_version:
required: true
default: master
description: '"master" or version nunmber ("3.1.2")'
type: string
ruby_commit_date_offset:
required: false
description: 'Commit date offset in days ("0")'
default: 0
type: choice
options:
- 0
- 1
ruby_sha:
required: false
description: 'SHA for master ruby_version (optional)'
type: string
env:
ruby_version: ${{ github.event.inputs.ruby_version || github.event.client_payload.ruby_version || 'master' }}
ruby_commit_date_offset: ${{ github.event.inputs.ruby_commit_date_offset || github.event.client_payload.ruby_commit_date_offset || '0' }}
ruby_sha: ${{ github.event.inputs.ruby_sha || github.event.client_payload.ruby_sha || '' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
ruby_sha: ${{ steps.ruby_sha.outputs.ruby_sha }}
steps:
- name: Resolve ruby_sha
id: ruby_sha
run: |-
if [ "$ruby_version" = master ] && [ -z "$ruby_sha" ]; then
for attempt in 1 2 3; do
ruby_sha=$(gh api repos/ruby/ruby/commits/master --jq .sha) && break
sleep 30
done
test -n "$ruby_sha"
fi
echo "ruby_sha=$ruby_sha" >> "$GITHUB_OUTPUT"
build:
needs: prepare
strategy:
fail-fast: false
matrix:
debug_suffix: ['', '-debug']
ubuntu_version:
- resolute
- noble
- jammy
arch: ['amd64', 'arm64']
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
env:
ruby_sha: ${{ needs.prepare.outputs.ruby_sha }}
ubuntu_version: "${{ matrix.ubuntu_version }}"
debug_suffix: ${{ matrix.debug_suffix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- run: |
if [ "${{ env.debug_suffix }}" = "-debug" ]; then
echo "cppflags=-DENABLE_PATH_CHECK=0 -DRUBY_DEBUG=1" >> $GITHUB_ENV
echo "optflags=-O3 -fno-inline" >> $GITHUB_ENV
fi
- name: Build and push docker images
run: |-
mkdir -p "$RUNNER_TEMP/digests"
for target in ruby development; do
for attempt in 1 2 3; do
rake docker:build ruby_version=${{ env.ruby_version }} \
ubuntu_version=${{ env.ubuntu_version }} \
arch=linux/${{ matrix.arch }} \
optflags="${{ env.optflags }}" \
cppflags="${{ env.cppflags }}" \
target=$target \
push_registries="rubylang ghcr.io/ruby" \
metadata_file="$RUNNER_TEMP/$target.json" && break
if [ $attempt = 3 ]; then exit 1; fi
sleep 60
done
jq -r '."containerimage.digest"' "$RUNNER_TEMP/$target.json" > "$RUNNER_TEMP/digests/$target-${{ matrix.arch }}"
done
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: digests${{ matrix.debug_suffix }}-${{ matrix.ubuntu_version }}-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
- uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
with:
payload: |
{
"attachments": [{
"text": "build ${{ job.status }}: ${{ matrix.ubuntu_version }} ${{ matrix.arch }} ${{ matrix.debug_suffix }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
deploy_multiarch:
strategy:
fail-fast: false
matrix:
debug_suffix: ['', '-debug']
ubuntu_version:
- resolute
- noble
- jammy
runs-on: ubuntu-latest
needs: [prepare, build]
if: ${{ !cancelled() && needs.prepare.result == 'success' }}
env:
ruby_sha: ${{ needs.prepare.outputs.ruby_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: digests${{ matrix.debug_suffix }}-${{ matrix.ubuntu_version }}-*
path: ${{ runner.temp }}/digests
merge-multiple: true
- name: Create and push manifests
run: |-
for target in ruby development; do
if [ $target = development ]; then dev_suffix=-dev; else dev_suffix=; fi
digests=$(cat "$RUNNER_TEMP/digests/$target-amd64" "$RUNNER_TEMP/digests/$target-arm64")
for registry_name in rubylang ghcr.io/ruby; do
rake docker:manifest:create \
registry_name="$registry_name" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ matrix.ubuntu_version }}" \
image_version_suffix=${{ matrix.debug_suffix }}$dev_suffix \
digests="$digests"
done
done
- uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
with:
payload: |
{
"attachments": [{
"text": "deploy_multiarch ${{ job.status }}: ${{ matrix.ubuntu_version }} ${{ matrix.debug_suffix }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()