-
Notifications
You must be signed in to change notification settings - Fork 134
210 lines (202 loc) · 6.34 KB
/
build.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
name: build
on:
pull_request:
push:
tags:
- "*"
- "!v*"
workflow_dispatch:
inputs:
branch_or_tag:
required: false
publish_release_artifacts:
type: boolean
required: true
default: false
jobs:
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
otp:
- 25.3.2-2
elixir:
- 1.14.5
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch_or_tag }}
fetch-depth: 0
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/metadata-action@v4
id: meta
with:
images: ${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/login-action@v2
if: startsWith(github.ref, 'refs/tags/') || inputs.publish_release_artifacts
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ startsWith(github.ref, 'refs/tags/') || inputs.publish_release_artifacts == true }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
FROM=ghcr.io/emqx/emqx-builder/5.2-3:${{ matrix.elixir }}-${{ matrix.otp }}-debian11
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
otp:
- 25.3.2-2
elixir:
- 1.14.5
quic_support:
- true
- false
os:
- ubuntu22.04
- ubuntu20.04
- ubuntu18.04
- ubuntu16.04
- debian12
- debian11
- debian10
- debian9
- el9
- el8
- el7
- amzn2
- amzn2023
container:
image: ghcr.io/emqx/emqx-builder/5.1-3:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch_or_tag }}
- shell: bash
run: |
[ "false" == ${{ matrix.quic_support }} ] && export BUILD_WITHOUT_QUIC=1
git config --global --add safe.directory $(pwd)
make
- if: failure()
run: cat rebar3.crashdump
- run: ./_build/emqtt_bench/rel/emqtt_bench/bin/emqtt_bench
- uses: actions/upload-artifact@v3
with:
name: packages
path: ./*.tar.gz
mac:
strategy:
fail-fast: false
matrix:
macos:
- macos-12-arm64
- macos-12
otp:
- 25.3.2-2
runs-on: ${{ matrix.macos }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch_or_tag }}
- name: prepare
run: |
brew install curl zip unzip gnu-sed kerl unixodbc freetds
echo "/usr/local/bin" >> $GITHUB_PATH
git config --global credential.helper store
- uses: actions/cache@v2
id: cache
with:
path: ~/.kerl
key: otp-${{ matrix.otp }}-${{ matrix.macos }}
- name: build erlang
if: steps.cache.outputs.cache-hit != 'true'
timeout-minutes: 60
env:
OTP: ${{ matrix.otp }}
run: |
set -eux
if [ ! -d $HOME/.kerl/$OTP ]; then
kerl build git https://github.com/emqx/otp.git OTP-$OTP $OTP
kerl install $OTP $HOME/.kerl/$OTP
fi
- name: Make
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_DEVELOPER_IDENTITY: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
APPLE_DEVELOPER_ID_BUNDLE: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }}
APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }}
run: |
. $HOME/.kerl/${{ matrix.otp }}/activate
make
- if: failure()
run: cat rebar3.crashdump
- run: ./_build/emqtt_bench/rel/emqtt_bench/bin/emqtt_bench
- uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/tags/') || inputs.publish_release_artifacts
with:
name: packages
path: ./*.zip
release:
runs-on: ubuntu-latest
needs:
- linux
- mac
if: startsWith(github.ref, 'refs/tags/') || inputs.publish_release_artifacts
steps:
- uses: actions/download-artifact@v3
with:
name: packages
path: packages
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Emqtt Bench ${{ github.ref }} Released
body: Emqtt Bench ${{ github.ref }} Released
draft: false
prerelease: false
- uses: Rory-Z/upload-release-asset@v1
with:
repo: emqtt-bench
path: "packages/emqtt-bench-*"
token: ${{ github.token }}
- uses: aws-actions/configure-aws-credentials@v1-node16
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: upload to aws s3
run: |
set -euo pipefail
aws s3 cp --recursive packages s3://${{ secrets.AWS_S3_BUCKET }}/emqtt-bench/${{ github.ref_name }}
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/emqtt-bench/${{ github.ref_name }}/*"
- name: update to emqx.io
run: |
set -eux
curl -w %{http_code} \
--insecure \
-H "Content-Type: application/json" \
-H "token: ${{ secrets.EMQX_IO_TOKEN }}" \
-X POST \
-d "{\"repo\":\"emqx/emqtt-bench\", \"tag\": \"${{ github.ref_name }}\" }" \
${{ secrets.EMQX_IO_RELEASE_API }}