How do you manage app versions in releases?

Both those set in distillery's rel/config.exs

release :my_release do
  set(version: "0.1.1") # <--- here

    applications: [
      # ...

and in each app’s mix.exs

  def project do
      app: :my_app,
      version: "0.1.5", # <--- here
      # ...

So far I’ve been naively setting them manually, but I’d like to somehow automate the process.

I’ve been thinking about setting the release version to a unix timestamp before each call to mix release. Are there any potential downsides to it? I mostly need it for hot code upgrades.

What can I do about individual app’s versions? Read them from environmental variables and add a pre-commit git hook that would increment those?

That’s what is in my rel/config.exs: set version: current_version(:my_app)

1 Like

I have several apps that should cause the release version to be incremented …

That’s from the elixir Version docs:

Build information can be added by appending +[0-9A-Za-z-.]:

So you could append the timestamps for different builds and use the release version for actually versionable changes in the umbrella topology.

1 Like

I’m not entirely happy with it, but for the time being each app in the umbrella sets its version by doing a Code.eval_file call to a common compile-time .exs file that reads the current git SHA and appends it to the base version.

1 Like

Curious if there have been any better ideas to come from the community for this. We also just manually increase the number.

I am using such script:

defmodule GitVersion do
  def version do
    case System.cmd(
           ~w[describe --always --dirty=+dirty],
           stderr_to_stdout: true
         ) do
      {raw, 0} ->
        case Version.parse(raw) do
          {:ok, version} ->
            |> bump_version()
            |> to_string()

          :error ->

      _ ->

  defp bump_version(%Version{pre: []} = version), do: version

  defp bump_version(%Version{patch: p} = version),
    do: struct(version, patch: p + 1)

In my mix.exs to extract version from the Git tags. TBH I would <3 to see something like that in Mix itself like there is {version, git} in Rebar3. This would make version management so much simpler.

1 Like