Merge pull request #3852 from zmstone/feat-add-build-stamp
Feat support build stamp and more fixes
This commit is contained in:
commit
12d706a84c
|
@ -32,3 +32,6 @@ xrefr
|
|||
etc/emqx.conf.rendered
|
||||
Mnesia.*/
|
||||
*.DS_Store
|
||||
_checkouts
|
||||
rebar.config.rendered
|
||||
/rebar3
|
||||
|
|
26
Makefile
26
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-%)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
|
@ -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.
|
|
@ -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}]).
|
||||
|
|
19
rebar.config
19
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}}"}
|
||||
]
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue