diff --git a/.gitignore b/.gitignore index d4cce2338..6ae33d8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ xrefr etc/emqx.conf.rendered Mnesia.*/ *.DS_Store +_checkouts +rebar.config.rendered +/rebar3 diff --git a/Makefile b/Makefile index 21179c5ea..b047ea8ef 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,22 @@ -REBAR = $(CURDIR)/rebar3 +REBAR_VERSION = 3.13.2-emqx-1 +REBAR = ./rebar3 PROFILE ?= emqx PROFILES := emqx emqx-edge PKG_PROFILES := emqx-pkg emqx-edge-pkg -export DEFAULT_VSN ?= $(shell ./get-lastest-tag.escript) -ifneq ($(shell echo $(DEFAULT_VSN) | grep -oE "^[ev0-9]+\.[0-9]+(\.[0-9]+)?"),) - export PKG_VSN := $(patsubst v%,%,$(patsubst e%,%,$(DEFAULT_VSN))) -else - export PKG_VSN := $(patsubst v%,%,$(DEFAULT_VSN)) -endif - .PHONY: default default: $(REBAR) $(PROFILE) .PHONY: all all: $(REBAR) $(PROFILES) +.PHONY: ensure-rebar3 +ensure-rebar3: + @./ensure-rebar3.sh $(REBAR_VERSION) + +$(REBAR): ensure-rebar3 + .PHONY: distclean distclean: @rm -rf _build @@ -34,11 +34,15 @@ endif $(PROFILES:%=build-%): $(REBAR) $(REBAR) as $(@:build-%=%) compile +# rebar clean .PHONY: clean $(PROFILES:%=clean-%) -clean: $(PROFILES:%=clean-%) +clean: $(PROFILES:%=clean-%) clean-stamps $(PROFILES:%=clean-%): $(REBAR) - @rm -rf _build/$(@:clean-%=%) - @rm -rf _build/$(@:clean-%=%)+test + $(REBAR) as $(@:clean-%=%) clean + +.PHONY: clean-stamps +clean-stamps: + find -L _build -name '.stamp' -type f | xargs rm -f .PHONY: deps-all deps-all: $(REBAR) $(PROFILES:%=deps-%) $(PKG_PROFILES:%=deps-%) diff --git a/apps/emqx_exhook/rebar.config b/apps/emqx_exhook/rebar.config index 0019ca245..1db04037f 100644 --- a/apps/emqx_exhook/rebar.config +++ b/apps/emqx_exhook/rebar.config @@ -1,7 +1,7 @@ %%-*- mode: erlang -*- {plugins, [rebar3_proper, - {grpcbox_plugin, {git, "https://github.com/HJianBo/grpcbox_plugin", {branch, "master"}}} + {grpcbox_plugin, {git, "https://github.com/zmstone/grpcbox_plugin", {branch, "master"}}} ]}. {deps, diff --git a/apps/emqx_exproto/rebar.config b/apps/emqx_exproto/rebar.config index e989b5aeb..bfc87e92c 100644 --- a/apps/emqx_exproto/rebar.config +++ b/apps/emqx_exproto/rebar.config @@ -9,7 +9,7 @@ {parse_transform}]}. {plugins, - [{grpcbox_plugin, {git, "https://github.com/HJianBo/grpcbox_plugin", {branch, "master"}}} + [{grpcbox_plugin, {git, "https://github.com/zmstone/grpcbox_plugin", {branch, "master"}}} ]}. {deps, diff --git a/ensure-rebar3.sh b/ensure-rebar3.sh new file mode 100755 index 000000000..5eaaca164 --- /dev/null +++ b/ensure-rebar3.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -euo pipefail + +VERSION="$1" + +download() { + curl -L "https://s3-us-west-2.amazonaws.com/packages.emqx/rebar/rebar3-${VERSION}" -o ./rebar3 +} + +version() { + ./rebar3 -v | grep -v '===' | grep 'rebar.*Erlang' | awk '{print $2}' +} + +if [ -f 'rebar3' ] && [ "$(version)" == "$VERSION" ]; then + exit 0 +fi + +download +chmod +x ./rebar3 diff --git a/get-lastest-tag.escript b/get-lastest-tag.escript deleted file mode 100755 index 5eb942b79..000000000 --- a/get-lastest-tag.escript +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env escript -%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- -%% ex: ft=erlang ts=4 sw=4 et -%% ------------------------------------------------------------------- -%% -%% nodetool: Helper Script for interacting with live nodes -%% -%% ------------------------------------------------------------------- - -main(_Args) -> - io:format(getRef()). - -comparingFun([C1|R1], [C2|R2]) when is_list(C1), is_list(C2); - is_integer(C1), is_integer(C2) -> C1 < C2 orelse comparingFun(R1, R2); -comparingFun([C1|R1], [C2|R2]) when is_integer(C1), is_list(C2) -> comparingFun(R1, R2); -comparingFun([C1|_R1], [C2|_R2]) when is_list(C1), is_integer(C2) -> true; -comparingFun(_, _) -> false. - -sortFun(T1, T2) -> - C = fun(T) -> - [case catch list_to_integer(E) of - I when is_integer(I) -> I; - _ -> E - end || E <- re:split(string:sub_string(T, 2), "[.-]", [{return, list}])] - end, - comparingFun(C(T1), C(T2)). - -latestTag(BranchName) -> - Tag = os:cmd("git describe --abbrev=1 --tags --always") -- "\n", - LatestTagCommitId = os:cmd(io_lib:format("git rev-parse --short ~s", [Tag])) -- "\n", - case string:tokens(os:cmd(io_lib:format("git tag -l \"v*\" --points-at ~s", [LatestTagCommitId])), "\n") of - [] -> BranchName ++ "-" ++ LatestTagCommitId; - Tags -> - lists:last(lists:sort(fun(T1, T2) -> sortFun(T1, T2) end, Tags)) - end. - -branch() -> - case os:getenv("GITHUB_RUN_ID") of - false -> os:cmd("git branch | grep -e '^*' | cut -d' ' -f 2") -- "\n"; - _ -> re:replace(os:getenv("GITHUB_REF"), "^refs/heads/|^refs/tags/", "", [global, {return ,list}]) - end. - -getRef() -> - case re:run(branch(), "master|^dev/|^hotfix/", [{capture, none}]) of - match -> branch(); - _ -> latestTag(branch()) - end. diff --git a/mods/mod_project.erl b/mods/mod_project.erl index df60cada1..ca5b23278 100644 --- a/mods/mod_project.erl +++ b/mods/mod_project.erl @@ -6,7 +6,7 @@ get_vsn(_Conf) -> PkgVsn = case os:getenv("PKG_VSN") of - false -> error({env_undefined, "PKG_VSN"}); + false -> os:cmd("git describe --tags"); Vsn -> Vsn end, re:replace(PkgVsn, "v", "", [{return ,list}]). diff --git a/rebar.config b/rebar.config index d555ecf8a..57928cef0 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,7 @@ {minimum_otp_vsn, "21.3"}. -{plugins,[{relup_helper,{git,"https://github.com/emqx/relup_helper", - {branch,"master"}}}]}. +{plugins,[ {relup_helper,{git,"https://github.com/emqx/relup_helper", {branch,"master"}}} + , {coveralls, {git, "https://github.com/emqx/coveralls-erl", {branch, "github"}}} + ]}. {edge_relx_overlay,[]}. {edoc_opts,[{preprocess,true}]}. {erl_opts,[warn_unused_vars,warn_shadow_vars,warn_unused_import, @@ -51,13 +52,7 @@ {overlay, ["${BASIC_OVERLAYS}", "${EDGE_OVERLAYS}"]}, {overlay_vars,["vars/vars-edge.config","vars/vars-pkg.config"]}]}]}, {test, - [ - {plugins, [ - rebar3_proper, - {coveralls, - {git, "https://github.com/emqx/coveralls-erl", - {branch, "github"}}}]}, - {deps, + [{deps, [ {bbmustache, "1.7.0"}, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.2.0"}}}, {emqx_ct_helpers, {git, "https://github.com/emqx/emqx-ct-helpers", {tag, "1.3.0"}}}, @@ -167,11 +162,11 @@ , {template, "data/loaded_plugins.tmpl", "data/loaded_plugins"} , {template, "data/loaded_modules.tmpl", "data/loaded_modules"} , {template,"data/emqx_vars","releases/emqx_vars"} - , {copy,"{{lib_dirs}}/cuttlefish/cuttlefish","bin/"} + , {copy,"_checkouts/cuttlefish/cuttlefish","bin/"} , {copy,"bin/*","bin/"} , {template,"etc/*.conf","etc/"} , {template,"etc/emqx.d/*.conf","etc/emqx.d/"} - , {copy,"{{lib_dirs}}/emqx/priv/emqx.schema","releases/{{rel_vsn}}/"} + , {copy,"_checkouts/emqx/priv/emqx.schema","releases/{{rel_vsn}}/"} , {copy, "etc/certs","etc/"} , "${RELUP_OVERLAYS}" ] @@ -184,7 +179,7 @@ , {copy,"bin/emqx_ctl","bin/emqx_ctl-{{rel_vsn}}"} , {copy,"bin/install_upgrade.escript", "bin/install_upgrade.escript-{{rel_vsn}}"} , {copy,"bin/nodetool","bin/nodetool-{{rel_vsn}}"} - , {copy,"{{lib_dirs}}/cuttlefish/cuttlefish","bin/cuttlefish-{{rel_vsn}}"} + , {copy,"_checkouts/cuttlefish/cuttlefish","bin/cuttlefish-{{rel_vsn}}"} ] }, diff --git a/rebar3 b/rebar3 deleted file mode 100755 index be1577243..000000000 Binary files a/rebar3 and /dev/null differ