-
Notifications
You must be signed in to change notification settings - Fork 10
171 lines (160 loc) · 5.82 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
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@v3
- 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: ubuntu-latest
strategy:
fail-fast: false
matrix:
base_image_vsn:
- "5.0"
platform:
- [ubuntu22.04 , "linux/amd64,linux/arm64"]
- [ubuntu20.04 , "linux/amd64,linux/arm64"]
- [ubuntu18.04 , "linux/amd64,linux/arm64"]
- [ubuntu16.04 , "linux/amd64,linux/arm64"]
- [debian12 , "linux/amd64,linux/arm64"]
- [debian11 , "linux/amd64,linux/arm64"]
- [debian10 , "linux/amd64,linux/arm64"]
- [debian9 , "linux/amd64,linux/arm64"]
- [el9 , "linux/amd64,linux/arm64"]
- [el8 , "linux/amd64,linux/arm64"]
- [el7 , "linux/amd64,linux/arm64"]
- [amzn2 , "linux/amd64,linux/arm64"]
- [amzn2023 , "linux/amd64,linux/arm64"]
- [alpine3.15.1, "linux/amd64,linux/arm64"]
steps:
- uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v2
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: Get cache
run: aws s3 sync s3://docker-buildx-cache/emqx-builder/${{ matrix.platform[0] }} /tmp/.docker-buildx-cache
- uses: docker/setup-buildx-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/metadata-action@v4
id: base_meta
with:
images: ghcr.io/${{ github.repository }}/base-${{ matrix.base_image_vsn }}
tags: type=raw,value=${{ matrix.platform[0] }}
- name: Build base image
uses: docker/build-push-action@v3
with:
push: true
pull: 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/${{ matrix.platform[0] }}
build:
runs-on: 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:
- [ubuntu22.04 , "linux/amd64,linux/arm64"]
- [ubuntu20.04 , "linux/amd64,linux/arm64"]
- [ubuntu18.04 , "linux/amd64,linux/arm64"]
- [ubuntu16.04 , "linux/amd64,linux/arm64"]
- [debian12 , "linux/amd64,linux/arm64"]
- [debian11 , "linux/amd64,linux/arm64"]
- [debian10 , "linux/amd64,linux/arm64"]
- [debian9 , "linux/amd64,linux/arm64"]
- [el9 , "linux/amd64,linux/arm64"]
- [el8 , "linux/amd64,linux/arm64"]
- [el7 , "linux/amd64,linux/arm64"]
- [amzn2 , "linux/amd64,linux/arm64"]
- [amzn2023 , "linux/amd64,linux/arm64"]
- [alpine3.15.1, "linux/amd64,linux/arm64"]
steps:
- uses: actions/checkout@v3
- name: Get ref
id: ref
run: echo "ref=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- uses: docker/setup-buildx-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/${{ github.repository }}/${{ steps.ref.outputs.ref }}
tags: |
type=raw,value=${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.platform[0] }}
- uses: docker/build-push-action@v3
with:
push: true
pull: true
no-cache: true
platforms: ${{ matrix.platform[1] }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_FROM=ghcr.io/${{ github.repository }}/base-${{ matrix.base_image_vsn }}:${{ matrix.platform[0] }}
OTP_VERSION=${{ matrix.otp }}
ELIXIR_VERSION=${{ matrix.elixir }}
file: ./Dockerfile
context: .
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: actions/create-release@v1
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