aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric <[email protected]>2012-09-12 16:58:11 -0500
committerEric <[email protected]>2012-09-12 17:14:58 -0500
commitbc35777bae4f66ddd1afade51d3c158cd6973c83 (patch)
tree1a14290a08df84c2a98866da98dea48ec1c7ebeb
parent00c3abbb52329043a1dd1b60941cca1de1eee11f (diff)
downloadrelx-bc35777bae4f66ddd1afade51d3c158cd6973c83.tar.gz
relx-bc35777bae4f66ddd1afade51d3c158cd6973c83.tar.bz2
relx-bc35777bae4f66ddd1afade51d3c158cd6973c83.zip
support incremental 'build versions' according to semver specs
-rw-r--r--src/relcool.app.src2
-rw-r--r--src/relcool.app.src.script22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/relcool.app.src b/src/relcool.app.src
index e2ce1e3..c2877a4 100644
--- a/src/relcool.app.src
+++ b/src/relcool.app.src
@@ -20,6 +20,6 @@
{application, relcool,
[{description, "Release assembler for Erlang/OTP Releases"},
- {vsn, "0.0.1"},
+ {vsn, git},
{modules, []},
{applications, [kernel, stdlib, getopt, depsolver, erlware_commons]}]}.
diff --git a/src/relcool.app.src.script b/src/relcool.app.src.script
new file mode 100644
index 0000000..381e7dc
--- /dev/null
+++ b/src/relcool.app.src.script
@@ -0,0 +1,22 @@
+%% -*- mode: Erlang; erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
+
+[{application, AppName, Details0}] = CONFIG,
+
+%% Get the tag timestamp and minimal ref from the system. The
+%% timestamp is really important from an ordering perspective.
+{ok, RawRef} = rebar_utils:sh("git log -n 1 --pretty=format:'%ct.%h\n' .", []),
+{ok, RawTag} = rebar_utils:sh("git describe --always --abbrev=0 --tags "
+ "`git log -n 1 --pretty=format:%h .`", []),
+
+%% Cleanup the tag and the Ref information. Basically leading 'v's and
+%% whitespace needs to go away.
+Tag = re:replace(RawTag, "(^v)|\\s", "", [global]),
+Ref = re:replace(RawRef, "\\s", "", [global]),
+
+%% Create the valid [semver](http://semver.org) version from the tag
+Vsn = erlang:binary_to_list(erlang:iolist_to_binary([Tag, "+build.", Ref])),
+
+%% Replace the old version with the new one
+Details1 = lists:keyreplace(vsn, 1, Details0, {vsn, Vsn}),
+
+[{application, AppName, Details1}].