|
1 | 1 | %%-*- mode: erlang -*-
|
2 |
| -%% emqx_management rebar.config.script |
3 |
| - |
4 |
| -CONFIG1 = case os:getenv("TRAVIS") of |
5 |
| - "true" -> |
6 |
| - JobId = os:getenv("TRAVIS_JOB_ID"), |
7 |
| - [{coveralls_service_job_id, JobId}, |
8 |
| - {coveralls_coverdata, "_build/test/cover/*.coverdata"}, |
9 |
| - {coveralls_service_name , "travis-ci"} | CONFIG]; |
10 |
| - _ -> |
11 |
| - CONFIG |
| 2 | + |
| 3 | +DEPS = case lists:keyfind(deps, 1, CONFIG) of |
| 4 | + {_, Deps} -> Deps; |
| 5 | + _ -> [] |
| 6 | + end, |
| 7 | + |
| 8 | +ComparingFun = fun |
| 9 | + _Fun([C1|R1], [C2|R2]) when is_list(C1), is_list(C2); |
| 10 | + is_integer(C1), is_integer(C2) -> C1 < C2 orelse _Fun(R1, R2); |
| 11 | + _Fun([C1|R1], [C2|R2]) when is_integer(C1), is_list(C2) -> _Fun(R1, R2); |
| 12 | + _Fun([C1|R1], [C2|R2]) when is_list(C1), is_integer(C2) -> true; |
| 13 | + _Fun(_, _) -> false |
| 14 | + end, |
| 15 | + |
| 16 | +SortFun = fun(T1, T2) -> |
| 17 | + C = fun(T) -> |
| 18 | + [case catch list_to_integer(E) of |
| 19 | + I when is_integer(I) -> I; |
| 20 | + _ -> E |
| 21 | + end || E <- re:split(string:sub_string(T, 2), "[.-]", [{return, list}])] |
| 22 | + end, |
| 23 | + ComparingFun(C(T1), C(T2)) |
12 | 24 | end,
|
13 | 25 |
|
14 |
| -DEPS = case lists:keyfind(deps, 1, CONFIG1) of |
15 |
| - {_, Deps} -> Deps; |
16 |
| - _ -> [] |
| 26 | +VTags = string:tokens(os:cmd("git tag -l \"v*\" --points-at $(git rev-parse $(git describe --abbrev=0 --tags))"), "\n"), |
| 27 | + |
| 28 | +Tags = case VTags of |
| 29 | + [] -> string:tokens(os:cmd("git tag -l \"e*\" --points-at $(git rev-parse $(git describe --abbrev=0 --tags))"), "\n"); |
| 30 | + _ -> VTags |
17 | 31 | end,
|
18 | 32 |
|
19 |
| -CUR_BRANCH = case os:getenv("GITHUB_RUN_ID") of |
20 |
| - false -> |
21 |
| - os:cmd("git branch | grep -e '^*' | cut -d' ' -f 2") -- "\n"; |
22 |
| - _ -> |
23 |
| - re:replace(os:getenv("GITHUB_REF"), ".*/", "", [global, {return ,list}]) |
24 |
| - end, |
25 |
| - |
26 |
| -MATCH_BRANCH = fun (BranchName) -> |
27 |
| - case re:run(BranchName, "^release|develop|master", [{capture, none}]) of |
28 |
| - match -> BranchName; |
29 |
| - _ -> case re:run(BranchName, "^[v]?[0-9]\.[0-9]\.([0-9]|(rc|beta|alpha)\.[0-9])", [{capture, none}]) of |
30 |
| - match -> BranchName; |
31 |
| - _ -> "develop" |
32 |
| - end |
33 |
| - end |
34 |
| - end, |
35 |
| - |
36 |
| -BRANCH = MATCH_BRANCH(CUR_BRANCH), |
| 33 | +LatestTag = lists:last(lists:sort(SortFun, Tags)), |
37 | 34 |
|
38 |
| -UrlPrefix = "https://github.com/emqx/", |
| 35 | +Branch = os:cmd("git branch | grep -e '^*' | cut -d' ' -f 2") -- "\n", |
39 | 36 |
|
40 |
| -EMQX_DEP = {emqx, {git, UrlPrefix ++ "emqx", {branch, BRANCH}}}, |
| 37 | +GitDescribe = case re:run(Branch, "master|^dev/|^hotfix/", [{capture, none}]) of |
| 38 | + match -> {branch, Branch}; |
| 39 | + _ -> {tag, LatestTag} |
| 40 | + end, |
| 41 | + |
| 42 | +UrlPrefix = "https://github.com/emqx/", |
41 | 43 |
|
42 |
| -EMQX_RELOADER_DEP = {emqx_reloader, {git, UrlPrefix ++ "emqx-reloader", {branch, BRANCH}}}, |
| 44 | +EMQX_DEP = {emqx, {git, UrlPrefix ++ "emqx", GitDescribe}}, |
| 45 | +EMQX_MGMT_DEP = {emqx_management, {git, UrlPrefix ++ "emqx-management", GitDescribe}}, |
43 | 46 |
|
44 |
| -NewDeps = [EMQX_DEP, EMQX_RELOADER_DEP | DEPS], |
| 47 | +NewDeps = [EMQX_DEP, EMQX_MGMT_DEP | DEPS], |
45 | 48 |
|
46 |
| -CONFIG2 = lists:keystore(deps, 1, CONFIG1, {deps, NewDeps}), |
| 49 | +CONFIG1 = lists:keystore(deps, 1, CONFIG, {deps, NewDeps}), |
47 | 50 |
|
48 |
| -CONFIG2. |
| 51 | +CONFIG1. |
0 commit comments