-
Notifications
You must be signed in to change notification settings - Fork 1
/
mix.exs
80 lines (68 loc) · 1.94 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
defmodule Sofa.MixProject do
use Mix.Project
def project do
[tag, version] = version()
[
app: :sofa,
version: tag,
id: version,
description: "Sofa " <> version,
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
# http://erlang.org/doc/man/dialyzer.html
dialyzer: [
flags: ["-Wunmatched_returns", :error_handling, :race_conditions],
list_unused_filters: true,
plt_local_path: System.user_home!() <> "/.mix/plts/sofa"
],
deps: deps()
]
end
def application do
[
extra_applications: [:logger],
mod: {Sofa.Application, []}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:idna, "~> 6.1", optional: true},
{:credo, "~> 1.3", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.1", only: :dev, runtime: false},
{:gun, "~> 2.0.0-rc.1", override: true, optional: true},
{:jason, "~> 1.2"},
{:tesla, "~> 1.4"}
]
end
defp version() do
case File.dir?(".git") do
false -> from_hex()
true -> from_git()
end
end
defp from_hex() do
File.read!(".version") |> String.split(":")
end
defp from_git() do
# pulls version information from "nearest" git tag or sha hash-ish
{hashish, 0} =
System.cmd("git", ~w[describe --dirty --abbrev=7 --tags --always --first-parent])
full_version = String.trim(hashish)
tag_version =
hashish
|> String.split("-")
|> List.first()
|> String.replace_prefix("v", "")
|> String.trim()
tag_version =
case Version.parse(tag_version) do
:error -> "0.0.0-#{tag_version}"
_ -> tag_version
end
# stash the tag so that it's rolled into the next commit and therefore
# available in hex packages when git tag info may not be present
File.write!(".version", "#{tag_version}: #{full_version}")
[tag_version, full_version]
end
end