version generation
This commit is contained in:
parent
62ffc00a5d
commit
baf58c1234
20
mix.exs
20
mix.exs
|
@ -176,7 +176,9 @@ defp version(version) do
|
||||||
ahead <- String.replace(describe, tag, "") do
|
ahead <- String.replace(describe, tag, "") do
|
||||||
{String.replace_prefix(tag, "v", ""), if(ahead != "", do: String.trim(ahead))}
|
{String.replace_prefix(tag, "v", ""), if(ahead != "", do: String.trim(ahead))}
|
||||||
else
|
else
|
||||||
_ -> {nil, nil}
|
_ ->
|
||||||
|
{commit_hash, 0} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
|
||||||
|
{nil, "-g" <> String.trim(commit_hash)}
|
||||||
end
|
end
|
||||||
|
|
||||||
if git_tag && version != git_tag do
|
if git_tag && version != git_tag do
|
||||||
|
@ -203,8 +205,18 @@ defp version(version) do
|
||||||
string -> "+" <> string
|
string -> "+" <> string
|
||||||
end).()
|
end).()
|
||||||
|
|
||||||
[version, git_pre_release, build]
|
branch_name =
|
||||||
|> Enum.filter(fn string -> string && string != "" end)
|
with {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
|
||||||
|> Enum.join()
|
true <- branch_name != "master" do
|
||||||
|
"-" <> String.trim(branch_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
full_version =
|
||||||
|
[version, git_pre_release, branch_name, build]
|
||||||
|
|> Enum.filter(fn string -> string && string != "" end)
|
||||||
|
|> Enum.join()
|
||||||
|
|
||||||
|
Mix.shell().info("Project version: #{full_version}")
|
||||||
|
full_version
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue