A simpler way to generate an incrementing version for elixir apps - Mercurial version

Posted on Wed 18 January 2017 in english

Maybe you've read this article about how to create incrementing versions for your Elixir apps with the help of Git tags. The Git tag is used as the release version Distillery uses.

This is the way you would it with the help of Mercurial:

1. Commit your new version and tag the commit:

hg commit -m "Version 0.3.0 released \o/"
hg tag 0.3.0
hg tags # show your tags

2. Add a new private function to your project's mix.exs:

defp app_version do
  {description, 0} = System.cmd("hg", ~w(log -r "." --template "{latesttag}"))
  String.replace(description, "\"", "")
end

3. Now use that function to automatically use the latest tagged commit:

defmodule TestProject.Mixfile do
  use Mix.Project
  def project do
    [app: :testproject,
     version: app_version(),
# ...

VĂ³ila!

# mix release
==> Assembling release..
==> Building release testproject:0.3.0 using environment dev
==> Packaging release..
==> Release successfully built!