test(CI): update matrix for build packages

This commit is contained in:
zhanghongtong 2020-12-30 14:40:12 +08:00 committed by Rory Z
parent 75381bc945
commit 72148c9e20
1 changed files with 51 additions and 75 deletions

View File

@ -107,6 +107,9 @@ jobs:
strategy: strategy:
matrix: matrix:
arch:
- amd64
- arm64
emqx: emqx:
- emqx - emqx
- emqx-edge - emqx-edge
@ -123,10 +126,20 @@ jobs:
- raspbian10 - raspbian10
- raspbian9 - raspbian9
exclude: exclude:
- emqx: emqx - os: raspbian9
os: raspbian9 arch: amd64
- emqx: emqx - os: raspbian9
os: raspbian10 emqx: emqx
- os: raspbian10
arch: amd64
- os: raspbian10
emqx: emqx
- os: centos6
arch: arm64
defaults:
run:
shell: bash
steps: steps:
- name: prepare docker - name: prepare docker
@ -150,43 +163,39 @@ jobs:
bash -c "make deps-all" bash -c "make deps-all"
- name: downloads emqx zip packages - name: downloads emqx zip packages
env: env:
EMQX: ${{ matrix.emqx }}
ARCH: ${{ matrix.arch }}
SYSTEM: ${{ matrix.os }} SYSTEM: ${{ matrix.os }}
run: | run: |
set -e -u -x set -e -u -x
version=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g") if [ $EMQX = "emqx-edge" ];then broker="emqx-edge"; else broker="emqx-ce"; fi
if [ "$(echo $version | grep -oE "^[ev0-9]+\.[0-9]+\.[1-9]?")" = "$version" ]; then if [ $ARCH = "arm64" ];then arch="aarch64"; else arch="x86_64"; fi
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 vsn="$(grep -oE '\{vsn, (.*)\}' src/emqx.app.src | sed -r 's/\{vsn, (.*)\}/\1/g' | sed 's/\"//g')"
cd tmp/relup_packages/emqx-edge pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')"
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 old_vsns=($(git tag -l "$pre_vsn.[0-9]" | sed "s/$vsn//"))
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 mkdir -p tmp/relup_packages/$EMQX
echo "$(cat emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256) emqx-edge-$SYSTEM-${tag#[e|v]}-$arch.zip" | sha256sum -c || exit 1 cd tmp/relup_packages/$EMQX
fi for tag in ${old_vsns[@]};do
cd - if [ ! -z "$(echo $(curl -I -m 10 -o /dev/null -s -w %{http_code} https://s3-us-west-2.amazonaws.com/packages.emqx/$broker/v${tag#[e|v]}/$EMQX-$SYSTEM-${tag#[e|v]}-$arch.zip) | grep -oE "^[23]+")" ];then
done wget https://s3-us-west-2.amazonaws.com/packages.emqx/$broker/v${tag#[e|v]}/$EMQX-$SYSTEM-${tag#[e|v]}-$arch.zip
done wget https://s3-us-west-2.amazonaws.com/packages.emqx/$broker/v${tag#[e|v]}/$EMQX-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256
fi echo "$(cat $EMQX-$SYSTEM-${tag#[e|v]}-$arch.zip.sha256) $EMQX-$SYSTEM-${tag#[e|v]}-$arch.zip" | sha256sum -c || exit 1
- name: build emqx packages on amd64 fi
env: done
cd -
- name: build emqx packages
if: (matrix.arch == 'amd64' && matrix.emqx == 'emqx') || startsWith(github.ref, 'refs/tags/')
env:
ERL_OTP: erl22.3 ERL_OTP: erl22.3
EMQX: ${{ matrix.emqx }} EMQX: ${{ matrix.emqx }}
ARCH: ${{ matrix.arch }}
SYSTEM: ${{ matrix.os }} SYSTEM: ${{ matrix.os }}
run: | run: |
set -e -u -x set -e -u -x
docker buildx build --no-cache \ docker buildx build --no-cache \
--platform=linux/amd64 \ --platform=linux/$ARCH \
-t cross_build_emqx_for_$SYSTEM \ -t cross_build_emqx_for_$SYSTEM \
-f .ci/build_packages/Dockerfile \ -f .ci/build_packages/Dockerfile \
--build-arg BUILD_FROM=emqx/build-env:$ERL_OTP-$SYSTEM \ --build-arg BUILD_FROM=emqx/build-env:$ERL_OTP-$SYSTEM \
@ -198,57 +207,24 @@ jobs:
mv emqx/_packages/$EMQX/* /tmp/packages/$EMQX/ mv emqx/_packages/$EMQX/* /tmp/packages/$EMQX/
rm -rf /tmp/cross-build-$EMQX-for-$SYSTEM.tar rm -rf /tmp/cross-build-$EMQX-for-$SYSTEM.tar
docker rm -f $(docker ps -a -q)
docker volume prune -f
- name: build emqx packages on arm64
if: matrix.os != 'centos6' && startsWith(github.ref, 'refs/tags/')
env:
ERL_OTP: erl22.3
EMQX: ${{ matrix.emqx }}
SYSTEM: ${{ matrix.os }}
run: |
set -e -u -x
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/_packages/$EMQX/*
mv emqx/_packages/$EMQX/* /tmp/packages/$EMQX/
rm -rf /tmp/cross-build-$EMQX-for-$SYSTEM.tar
docker rm -f $(docker ps -a -q) docker rm -f $(docker ps -a -q)
docker volume prune -f docker volume prune -f
- name: create sha256 - name: create sha256
env:
EMQX: ${{ matrix.emqx }}
run: | run: |
if [ -d /tmp/packages/emqx ]; then if [ -d /tmp/packages/$EMQX ]; then
cd /tmp/packages/emqx cd /tmp/packages/$EMQX
for var in $(ls emqx-* ); do for var in $(ls emqx-* ); do
bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256" bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"
done done
cd - cd -
fi 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: startsWith(github.ref, 'refs/tags/') && matrix.os != 'raspbian9' && matrix.os != 'raspbian10'
with:
name: emqx
path: /tmp/packages/emqx/.
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
name: emqx-edge name: ${{ matrix.emqx }}
path: /tmp/packages/emqx-edge/. path: /tmp/packages/${{ matrix.emqx }}/.
docker: docker:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -256,11 +232,11 @@ jobs:
strategy: strategy:
matrix: matrix:
arch: arch:
- [amd64, x86_64] - [amd64, x86_64]
- [arm64v8, aarch64] - [arm64v8, aarch64]
- [arm32v7, arm] - [arm32v7, arm]
- [i386, i386] - [i386, i386]
- [s390x, s390x] - [s390x, s390x]
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1