/
hex_release.ex
54 lines (42 loc) · 1.23 KB
/
hex_release.ex
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
defmodule Mix.Tasks.HexRelease do
use Mix.Task
@shortdoc "Publish package to hex.pm, create a git tag and push it to GitHub"
@moduledoc """
release uses shipit.
It performs many sanity checks before pushing the hex package.
Check out https://github.com/wojtekmach/shipit for more details
"""
def run([]) do
ensure_shipit_installed!()
Mix.Task.run("shipit", ["master", current_version()])
end
def run(_) do
Mix.raise("""
Invalid args.
Usage:
mix release
""")
end
defp ensure_shipit_installed! do
loadpaths!()
Mix.Task.load_all()
if !Mix.Task.get("shipit") do
Mix.raise("""
You don't seem to have the shipit mix task installed on your computer.
Install it using:
mix archive.install hex shipit
Fore more info go to: https://github.com/wojtekmach/shipit
""")
end
end
defp current_version do
Mix.Project.config[:version]
end
# Copied from Mix.Tasks.Help
# Loadpaths without checks because tasks may be defined in deps.
defp loadpaths! do
Mix.Task.run "loadpaths", ["--no-elixir-version-check", "--no-deps-check", "--no-archives-check"]
Mix.Task.reenable "loadpaths"
Mix.Task.reenable "deps.loadpaths"
end
end