Packages
version_tasks
0.10.29
0.12.0
0.11.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.29
0.10.28
0.10.27
0.10.26
0.10.25
0.10.24
0.10.23
0.10.22
0.10.21
0.10.20
0.10.19
0.10.18
0.10.17
0.10.16
0.10.15
0.10.14
0.10.13
0.10.12
0.10.11
0.10.10
0.10.9
0.10.8
0.10.7
0.10.6
0.10.5
0.10.4
0.10.3
0.10.1
0.10.0
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.3
0.8.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.3
0.3.1
0.2.6
A suite of mix tasks for managing your libs version numbers with git and hex
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/githooks/deploy.ex
defmodule Mix.Tasks.Githooks.Deploy do
use Mix.Task
@shortdoc "Install a githook to run ./bin/deploy on a new release"
def run([]), do: run(["bin/deploy"])
def run([deploy_filename]) do
post_commit_filename = ".git/hooks/post-commit"
content = """
#!/bin/bash
if [ "$(MIX_QUIET=true mix version.is_release)" != "" ]; then
./bin/deploy
else
echo "Continue making the app awesome."
fi
"""
File.write!(post_commit_filename, content)
:ok = File.chmod(post_commit_filename, 0o755)
unless File.exists?(deploy_filename) do
deploy_filename |> Path.dirname |> Path.expand |> File.mkdir_p!
content = """
#!/bin/bash
VERSION=$(MIX_QUIET=1 mix version.current)
echo "================="
echo "DEPLOYING $VERSION"
echo "Based on script in #{deploy_filename}"
echo "By default it does nothing but runs your tests"
echo "and tags your release. So please update with"
echo "what you need to do"
echo "================="
mix test && \\
mix version.tag
"""
File.write!(deploy_filename, content)
:ok = File.chmod(deploy_filename, 0o755)
end
IO.puts "Installed #{post_commit_filename}"
IO.puts "which will run #{deploy_filename}"
IO.puts "after a 'mix version.up'"
post_commit_filename
end
end