-
Notifications
You must be signed in to change notification settings - Fork 10
292 lines (278 loc) · 12.5 KB
/
main.yaml
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: Build docker images
concurrency:
group: main-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
tags:
- "*"
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
otp: ${{ steps.otp.outputs.version }}
elixir: ${{ steps.elixir.outputs.version }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: get otp_version
id: otp
run: |
otp_version=$(grep -E "^\+\sOTP-.*" ./RELEASE.md | sed 's/\+\sOTP-//g' | jq -R -s -c 'split("\n")[:-1]')
echo "version=$otp_version" >> $GITHUB_OUTPUT
- name: get elixir_version
id: elixir
run: |
elixir_version=$(grep -E "^\+\sElixir-.*" ./RELEASE.md | sed 's/\+\sElixir-//g' | jq -R -s -c 'split("\n")[:-1]')
echo "version=$elixir_version" >> $GITHUB_OUTPUT
base:
runs-on: ${{ github.repository_owner == 'emqx' && matrix.platform[2] || '["ubuntu-latest"]' }}
strategy:
fail-fast: false
matrix:
base_image_vsn:
- "5.0"
platform:
- [ubuntu24.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu24.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [ubuntu22.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu22.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [ubuntu20.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu20.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [ubuntu18.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu18.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [debian12, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [debian12, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [debian11, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [debian11, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [debian10, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [debian10, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [el9, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [el9, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [el8, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [el8, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [el7, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [el7, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [amzn2, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [amzn2, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [amzn2023, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [amzn2023, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [alpine3.15.1, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [alpine3.15.1, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/base-${{ matrix.base_image_vsn }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: define base tag
id: base_tag
run: |
PLATFORM=${{ matrix.platform[1] }}
ARCH=${PLATFORM#linux/}
echo "tag=${{ matrix.platform[0] }}-${ARCH}" | tee -a $GITHUB_OUTPUT
- name: Get cache
run: aws s3 sync s3://docker-buildx-cache/emqx-builder/${{ steps.base_tag.outputs.tag }} /tmp/.docker-buildx-cache
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
id: base_meta
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: type=raw,value=${{ steps.base_tag.outputs.tag }}
- name: Build base image
id: build
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
pull: true
push: true
cache-from: type=local,src=/tmp/.docker-buildx-cache,mode=max
cache-to: type=local,dest=/tmp/.docker-buildx-cache-new,mode=max
platforms: ${{ matrix.platform[1] }}
tags: ${{ steps.base_meta.outputs.tags }}
labels: ${{ steps.base_meta.outputs.labels }}
file: ${{ matrix.platform[0] }}/Dockerfile
context: .
- name: Update cache
run: aws s3 sync --delete /tmp/.docker-buildx-cache-new s3://docker-buildx-cache/emqx-builder/${{ steps.base_tag.outputs.tag }}
build:
runs-on: ${{ github.repository_owner == 'emqx' && matrix.platform[2] || '["ubuntu-latest"]' }}
needs:
- prepare
- base
strategy:
fail-fast: false
matrix:
base_image_vsn:
- "5.0"
otp: ${{ fromJSON(needs.prepare.outputs.otp) }}
elixir: ${{ fromJSON(needs.prepare.outputs.elixir) }}
platform:
- [ubuntu24.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu24.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [ubuntu22.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu22.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [ubuntu20.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu20.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [ubuntu18.04, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [ubuntu18.04, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [debian12, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [debian12, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [debian11, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [debian11, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [debian10, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [debian10, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [el9, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [el9, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [el8, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [el8, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [el7, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [el7, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [amzn2, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [amzn2, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [amzn2023, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [amzn2023, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
- [alpine3.15.1, linux/amd64, [self-hosted, linux, x64, ephemeral]]
- [alpine3.15.1, linux/arm64, [self-hosted, linux, arm64, ephemeral]]
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Get ref
id: ref
run: echo "ref=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Set registry image
id: registry
run: |
echo "image=ghcr.io/${{ github.repository }}/${{ steps.ref.outputs.ref }}" | tee -a $GITHUB_OUTPUT
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
id: meta
with:
images: ${{ steps.registry.outputs.image }}
- name: define base tag
id: base_tag
run: |
PLATFORM=${{ matrix.platform[1] }}
ARCH="${PLATFORM#linux/}"
TAG="${{ matrix.platform[0] }}-${ARCH}"
echo "tag=${TAG}" | tee -a $GITHUB_OUTPUT
echo "image=ghcr.io/${{ github.repository }}/base-${{ matrix.base_image_vsn }}:${TAG}" | tee -a $GITHUB_OUTPUT
- uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
id: build
with:
pull: true
no-cache: true
platforms: ${{ matrix.platform[1] }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_FROM=${{ steps.base_tag.outputs.image }}
OTP_VERSION=${{ matrix.otp }}
ELIXIR_VERSION=${{ matrix.elixir }}
file: ./Dockerfile
context: .
outputs: type=image,name=${{ steps.registry.outputs.image }},push-by-digest=true,name-canonical=true,push=true
- name: Export digests
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: "digests-${{ matrix.platform[0] }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ matrix.platform[1] == 'linux/amd64' && 'amd64' || 'arm64' }}"
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- prepare
- build
strategy:
fail-fast: false
matrix:
base_image_vsn:
- "5.0"
otp: ${{ fromJSON(needs.prepare.outputs.otp) }}
elixir: ${{ fromJSON(needs.prepare.outputs.elixir) }}
platform:
- ubuntu24.04
- ubuntu22.04
- ubuntu20.04
- ubuntu18.04
- debian12
- debian11
- debian10
- el9
- el8
- el7
- amzn2
- amzn2023
- alpine3.15.1
steps:
- name: Get ref
id: ref
run: echo "ref=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Set registry image
id: registry
run: |
echo "image=ghcr.io/${{ github.repository }}/${{ steps.ref.outputs.ref }}" | tee -a $GITHUB_OUTPUT
- name: Download digests
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
pattern: "digests-${{ matrix.platform }}-${{ matrix.otp }}-${{ matrix.elixir }}-*"
path: /tmp/digests
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ steps.registry.outputs.image }}
tags: |
type=raw,value=${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.platform }}
- name: Login to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.registry.outputs.image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ steps.registry.outputs.image }}:${{ steps.meta.outputs.version }}
release:
runs-on: ubuntu-latest
needs: merge
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Create Release
id: create_release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ github.ref }}
release_name: EMQX Builder ${{ github.ref }} Released
body_path: RELEASE.md
draft: false
prerelease: false