From 4e755d80db9e8a3206c1fd11d5d1a63998350d38 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 30 Nov 2020 19:48:02 +0100 Subject: [PATCH 1/2] refactor(build): Download rebar3 from github release --- Makefile | 2 +- ensure-rebar3.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b047ea8ef..40d3c325c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -REBAR_VERSION = 3.13.2-emqx-1 +REBAR_VERSION = 3.13.2-emqx-2 REBAR = ./rebar3 PROFILE ?= emqx diff --git a/ensure-rebar3.sh b/ensure-rebar3.sh index 5eaaca164..626dd1bc1 100755 --- a/ensure-rebar3.sh +++ b/ensure-rebar3.sh @@ -4,8 +4,9 @@ set -euo pipefail VERSION="$1" +DOWNLOAD_URL='https://github.com/emqx/rebar3/releases/download' download() { - curl -L "https://s3-us-west-2.amazonaws.com/packages.emqx/rebar/rebar3-${VERSION}" -o ./rebar3 + curl -L "${DOWNLOAD_URL}/${VERSION}/rebar3" -o ./rebar3 } version() { From cafa5479962debe45cb3c10e8ed45a25ccaf7049 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 30 Nov 2020 19:48:31 +0100 Subject: [PATCH 2/2] refactor(build): Get rebar3 version from escript header comments The command rebar3 --version loads rebar config and prints logs --- ensure-rebar3.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ensure-rebar3.sh b/ensure-rebar3.sh index 626dd1bc1..0d77be44a 100755 --- a/ensure-rebar3.sh +++ b/ensure-rebar3.sh @@ -5,12 +5,16 @@ set -euo pipefail VERSION="$1" DOWNLOAD_URL='https://github.com/emqx/rebar3/releases/download' + download() { curl -L "${DOWNLOAD_URL}/${VERSION}/rebar3" -o ./rebar3 } +# get the version number from the second line of the escript +# because command `rebar3 -v` tries to load rebar.config +# which is slow and may print some logs version() { - ./rebar3 -v | grep -v '===' | grep 'rebar.*Erlang' | awk '{print $2}' + head -n 2 ./rebar3 | tail -n 1 | tr ' ' '\n' | grep -E '^.+-emqx-.+' } if [ -f 'rebar3' ] && [ "$(version)" == "$VERSION" ]; then