-
Notifications
You must be signed in to change notification settings - Fork 221
392 lines (362 loc) · 15.4 KB
/
build_cross_packages.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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
name: Cross build packages
on:
pull_request:
push:
tags:
- v*
jobs:
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: ilammy/msvc-dev-cmd@v1
- uses: gleam-lang/setup-erlang@v1.1.0
id: install_erlang
with:
otp-version: 22.3
- name: build
run: |
# set-executionpolicy remotesigned -s cu
# iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
# # $env:path + ";" + $env:USERPROFILE + "\scoop\shims" + ';C:\Program Files\erl10.4\bin'
# [environment]::SetEnvironmentvariable("Path", ";" + $env:USERPROFILE + "\scoop\shims")
# [environment]::SetEnvironmentvariable("Path", ';C:\Program Files\erl10.4\bin')
# scoop bucket add extras https://github.com/lukesampson/scoop-extras.git
# scoop update
# scoop install sudo curl vcredist2013
$env:PATH = "${{ steps.install_erlang.outputs.erlpath }}\bin;$env:PATH"
$version = $( "${{ github.ref }}" -replace "^(.*)/(.*)/" )
if ($version -match "^v[0-9]+\.[0-9]+(\.[0-9]+)?") {
$env:EMQX_DEPS_DEFAULT_VSN = $version
$regex = "[0-9]+\.[0-9]+(-alpha|-beta|-rc)?\.[0-9]"
$pkg_name = "emqx-windows-$([regex]::matches($version, $regex).value).zip"
}
else {
$env:EMQX_DEPS_DEFAULT_VSN = ""
$pkg_name = "emqx-windows-$($version -replace '/').zip"
}
make deps-emqx
$rebar3 = $env:USERPROFILE + "\rebar3"
(New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/rebar3/rebar3', $rebar3)
cd _build/emqx/lib/jiffy/
escript $rebar3 compile
cd ../../../../
make emqx
mkdir -p _packages/emqx
Compress-Archive -Path _build/emqx/rel/emqx -DestinationPath _build/emqx/rel/$pkg_name
mv _build/emqx/rel/$pkg_name _packages/emqx
Get-FileHash -Path "_packages/emqx/$pkg_name" | Format-List | grep 'Hash' | awk '{print $3}' > _packages/emqx/$pkg_name.sha256
- name: run emqx
run: |
./_build/emqx/rel/emqx/bin/emqx start
./_build/emqx/rel/emqx/bin/emqx stop
./_build/emqx/rel/emqx/bin/emqx install
./_build/emqx/rel/emqx/bin/emqx uninstall
- uses: actions/upload-artifact@v1
with:
name: emqx
path: ./_packages/emqx/.
mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: prepare
run: |
brew install curl zip unzip gnu-sed erlang@22 openssl@1.1
echo "/usr/local/opt/erlang@22/bin" >> $GITHUB_PATH
echo "/usr/local/bin" >> $GITHUB_PATH
- name: build
run: make emqx-pkg
- name: test
run: |
pkg_name=$(basename _packages/emqx/emqx-macos-*.zip)
unzip _packages/emqx/$pkg_name
./emqx/bin/emqx start
./emqx/bin/emqx_ctl status
./emqx/bin/emqx stop
rm -rf emqx
openssl dgst -sha256 ./_packages/emqx/$pkg_name | awk '{print $2}' > ./_packages/emqx/$pkg_name.sha256
# - uses: actions/upload-artifact@v1
# with:
# name: emqx
# path: ./_packages/emqx/.
linux:
runs-on: ubuntu-latest
strategy:
matrix:
os:
- ubuntu20.04
- ubuntu18.04
- ubuntu16.04
- debian10
- debian9
- opensuse
- centos8
- centos7
- centos6
- raspbian10
- raspbian9
steps:
- name: prepare docker
run: |
mkdir -p $HOME/.docker
echo '{ "experimental": "enabled" }' | tee $HOME/.docker/config.json
echo '{ "experimental": true, "storage-driver": "overlay2", "max-concurrent-downloads": 50, "max-concurrent-uploads": 50}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
docker info
docker buildx create --use --name mybuild
docker run --rm --privileged tonistiigi/binfmt --install all
- uses: actions/checkout@v1
- name: get deps
run: |
docker run -i --rm \
-e GITHUB_RUN_ID=$GITHUB_RUN_ID \
-e GITHUB_REF=$GITHUB_REF \
-v $(pwd):/emqx-rel \
-w /emqx-rel \
emqx/build-env:erl22.3-debian10 \
bash -c "make deps-all"
- name: downloads emqx zip packages
env:
SYSTEM: ${{ matrix.os }}
run: |
set -e -u -x
version=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g")
if [ "$(echo $version | grep -oE "^[ev0-9]+\.[0-9]+\.[1-9]+?")" = "$version" ]; then
tags=$(git tag -l "$(echo $version | grep -oE "^[ev0-9]+\.[0-9]").*" |grep -v "$version")
for tag in ${tags[@]};do
for arch in x86_64 aarch64; do
mkdir -p tmp/relup_packages/emqx
cd tmp/relup_packages/emqx
if [ ! -z "$(echo $(curl -I -m 10 -o /dev/null -s -w %{http_code} https://packages.emqx.io/emqx-ce/v${tag#[e|v]}/emqx-$SYSTEM-${tag#[e|v]}-$arch.zip) | grep -oE "^[23]+")" ];then
wget https://www.emqx.io/downloads/broker/v${tag#[e|v]}/emqx-$SYSTEM-${tag#[e|v]}-$arch.zip
wget https://www.emqx.io/downloads/broker/v${tag#[e|v]}/emqx-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256
echo "$(cat emqx-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256) emqx-$SYSTEM-${tag#[e|v]}-$arch.zip" | sha256sum -c || exit 1
fi
cd -
mkdir -p tmp/relup_packages/emqx-edge
cd tmp/relup_packages/emqx-edge
if [ ! -z "$(echo $(curl -I -m 10 -o /dev/null -s -w %{http_code} https://packages.emqx.io/emqx-edge/v${tag#[e|v]}/emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip) | grep -oE "^[23]+")" ];then
wget https://www.emqx.io/downloads/edge/v${tag#[e|v]}/emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip
wget https://www.emqx.io/downloads/edge/v${tag#[e|v]}/emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256
echo "$(cat emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256) emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip" | sha256sum -c || exit 1
fi
cd -
done
done
fi
- name: build emqx packages on amd64
env:
ERL_OTP: erl22.3
SYSTEM: ${{ matrix.os }}
if: matrix.os != 'raspbian9' && matrix.os != 'raspbian10'
run: |
set -e -u -x
for EMQX in emqx emqx-edge; do
docker buildx build --no-cache \
--platform=linux/amd64 \
-t cross_build_emqx_for_$SYSTEM \
-f .ci/build_packages/Dockerfile \
--build-arg BUILD_FROM=emqx/build-env:$ERL_OTP-$SYSTEM \
--build-arg EMQX_NAME=${EMQX} \
--output type=tar,dest=/tmp/cross-build-$EMQX-for-$SYSTEM.tar .
mkdir -p /tmp/packages/$EMQX
tar -xvf /tmp/cross-build-$EMQX-for-$SYSTEM.tar --wildcards emqx-rel/_packages/$EMQX/*
mv emqx-rel/_packages/$EMQX/* /tmp/packages/$EMQX/
rm -rf /tmp/cross-build-$EMQX-for-$SYSTEM.tar
docker rm -f $(docker ps -a -q)
docker volume prune -f
done
- name: build emqx packages on arm64
if: matrix.os != 'centos6'
env:
ERL_OTP: erl22.3
SYSTEM: ${{ matrix.os }}
run: |
set -e -u -x
for EMQX in emqx emqx-edge; do
if [ "$EMQX" == "emqx" ] && [ ! -z $( echo $SYSTEM | grep -o raspbian) ];then
continue
fi
docker buildx build --no-cache \
--platform=linux/arm64 \
-t cross_build_emqx_for_$SYSTEM \
-f .ci/build_packages/Dockerfile \
--build-arg BUILD_FROM=emqx/build-env:$ERL_OTP-$SYSTEM \
--build-arg EMQX_NAME=${EMQX} \
--output type=tar,dest=/tmp/cross-build-$EMQX-for-$SYSTEM.tar . || df -h
mkdir -p /tmp/packages/$EMQX
tar -xvf /tmp/cross-build-$EMQX-for-$SYSTEM.tar --wildcards emqx-rel/_packages/$EMQX/*
mv emqx-rel/_packages/$EMQX/* /tmp/packages/$EMQX/
rm -rf /tmp/cross-build-$EMQX-for-$SYSTEM.tar
docker rm -f $(docker ps -a -q)
docker volume prune -f
done
- name: create sha256
run: |
if [ -d /tmp/packages/emqx ]; then
cd /tmp/packages/emqx
for var in $(ls emqx-* ); do
bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"
done
cd -
fi
if [ -d /tmp/packages/emqx-edge ]; then
cd /tmp/packages/emqx-edge
for var in $(ls emqx-edge-* ); do
bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"
done
cd -
fi
- uses: actions/upload-artifact@v1
if: matrix.os != 'raspbian9' && matrix.os != 'raspbian10'
with:
name: emqx
path: /tmp/packages/emqx/.
- uses: actions/upload-artifact@v1
with:
name: emqx-edge
path: /tmp/packages/emqx-edge/.
docker:
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- [amd64, x86_64]
- [arm64v8, aarch64]
- [arm32v7, arm]
- [i386, i386]
- [s390x, s390x]
steps:
- uses: actions/checkout@v1
- name: get deps
run: |
docker run -i --rm \
-e GITHUB_RUN_ID=$GITHUB_RUN_ID \
-e GITHUB_REF=$GITHUB_REF \
-v $(pwd):/emqx-rel \
-w /emqx-rel \
emqx/build-env:erl22.3-alpine-amd64 \
sh -c "make deps-emqx"
- name: build emqx docker image
env:
ARCH: ${{ matrix.arch[0] }}
QEMU_ARCH: ${{ matrix.arch[1] }}
run: |
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
sudo TARGET=emqx/emqx ARCH=$ARCH QEMU_ARCH=$QEMU_ARCH make docker
cd _packages/emqx && for var in $(ls emqx-docker-* ); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd -
sudo TARGET=emqx/emqx-edge ARCH=$ARCH QEMU_ARCH=$QEMU_ARCH make docker
cd _packages/emqx-edge && for var in $(ls emqx-edge-docker-* ); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd -
- name: docker test
if: matrix.arch[0] == 'amd64'
run: |
sudo TARGET=emqx/emqx PAHO_BRANCH="develop-4.0" make -C .ci/paho_tests cluster_test
sudo TARGET=emqx/emqx-edge PAHO_BRANCH="develop-4.0" make -C .ci/paho_tests cluster_test
- uses: actions/upload-artifact@v1
with:
name: emqx
path: ./_packages/emqx/.
- uses: actions/upload-artifact@v1
with:
name: emqx-edge
path: ./_packages/emqx-edge/.
upload:
runs-on: ubuntu-latest
needs: [windows, mac, linux, docker]
steps:
- uses: actions/download-artifact@v2
with:
name: emqx
path: ./_packages/emqx
- uses: actions/download-artifact@v2
with:
name: emqx-edge
path: ./_packages/emqx-edge
- uses: geekyeggo/delete-artifact@v1
with:
name: emqx
- uses: geekyeggo/delete-artifact@v1
with:
name: emqx-edge
- name: install dos2unix
run: sudo apt-get update && sudo apt install -y dos2unix
- name: get packages
run: |
set -e -x -u
version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g")
for EMQX in emqx emqx-edge; do
cd _packages/$EMQX
for var in $( ls |grep emqx |grep -v sha256); do
dos2unix $var.sha256
echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
done
cd -
done
- name: upload aws s3
run: |
set -e -x -u
version=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g")
if [ ! -z $(echo $version | grep -oE "^[ev0-9]+\.[0-9]+(\.[0-9]+)?") ]; then
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set default.region us-west-2
aws s3 cp --recursive _packages/emqx s3://packages.emqx/emqx-ce/$version
aws s3 cp --recursive _packages/emqx-edge s3://packages.emqx/emqx-edge/$version
aws cloudfront create-invalidation --distribution-id E170YEULGLT8XB --paths "/emqx-ce/$version/*,/emqx-edge/$version/*"
mkdir packages
mv _packages/emqx/* packages
mv _packages/emqx-edge/* packages
fi
- uses: actions/checkout@v2
with:
path: emqx-rel
- name: update to github and emqx.io
run: |
set -e -x -u
version=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g")
if [ ! -z $(echo $version | grep -oE "^[ev0-9]+\.[0-9]+(\.[0-9]+)?") ]; then
cd packages
for var in $(ls); do
../emqx-rel/.ci/build_packages/upload_github_release_asset.sh owner=emqx repo=emqx tag=$version filename=$var github_api_token=$(echo ${{ secrets.AccessToken }})
sleep 1
done
curl -w %{http_code} \
--insecure \
-H "Content-Type: application/json" \
-H "token: ${{ secrets.EMQX_IO_TOKEN }}" \
-X POST \
-d "{\"repo\":\"emqx/emqx\", \"tag\": \"${version}\" }" \
${{ secrets.EMQX_IO_RELEASE_API }}
fi
- name: push docker image to docker hub
run: |
set -e -x -u
version=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g")
if [ ! -z $(echo $version | grep -oE "^[ev0-9]+\.[0-9]+(\.[0-9]+)?") ]; then
sudo make -C emqx-rel docker-prepare
cd packages && for var in $(ls |grep docker |grep -v sha256); do unzip $var; sudo docker load < ${var%.*}; rm -f ${var%.*}; done && cd -
echo ${{ secrets.DOCKER_HUB_TOKEN }} |sudo docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin
sudo EMQX_DEPS_DEFAULT_VSN=$version TARGET=emqx/emqx make -C emqx-rel docker-push
sudo EMQX_DEPS_DEFAULT_VSN=$version TARGET=emqx/emqx make -C emqx-rel docker-manifest-list
sudo EMQX_DEPS_DEFAULT_VSN=$version TARGET=emqx/emqx-edge make -C emqx-rel docker-push
sudo EMQX_DEPS_DEFAULT_VSN=$version TARGET=emqx/emqx-edge make -C emqx-rel docker-manifest-list
fi
- name: update repo.emqx.io
run: |
set -e -x -u
version=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g")
if [ ! -z $(echo $version | grep -oE "^[ev0-9]+\.[0-9]+(\.[0-9]+)?") ]; then
curl \
-H "Authorization: token ${{ secrets.AccessToken }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
-d "{\"ref\":\"v1.0.0\",\"inputs\":{\"version\": \"${version}\", \"emqx_ce\": \"true\"}}" \
https://api.github.com/repos/emqx/emqx-ci-helper/actions/workflows/update_repos.yaml/dispatches
fi
# - name: update homebrew packages
# run: |
# version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g")
# if [ ! -z $(echo $version | grep -oE "v[0-9]+\.[0-9]+(\.[0-9]+)?") ] && [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then
# curl -H "Authorization: token ${{ secrets.AccessToken }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" -X POST -d "{\"event_type\":\"update_homebrew\",\"client_payload\":{\"version\": \"$version\"}}" https://api.github.com/repos/emqx/emqx-packages-docker/dispatches
# fi