edeliver v1.8.0 mix release.version

Displays the release version or modifies it before building the release.

This task can be used in conjunction with the release task to modify the version for the release / upgrade. The compiled files must be cleaned before and the release task must be executed after. Increasing version and appending metadata to the version can be combined, e.g:

mix do clean, release.version increment minor append-git-revision append-branch, release

To automatically append metadata, you can set the $AUTO_VERSION environment variable.

Usage:

  • mix release.version show
  • mix do clean, release.version Append-Metadata... [Option], release
  • mix do clean, release.version increment [patch|minor|major] [version] [Append-Metadata...] [Option], release
  • mix do clean, release.version set <new-version> [Append-Metadata...] [Option], release

Append-Metadata

  • [append-][git-]revision Appends sha1 git revision of current HEAD
  • [append-][git-]branch[-unless-master] Appends the current branch that is built. If -unless-master is used, the branch is only appended unless it is the master branch.
  • [append-][build-]date Appends the build date as YYYYMMDD
  • [append-][build-]time Appends the build date as HHMMSS
  • [append-][git-]commit-count[-all[-branches]|-branch] Appends the number of commits
  • [append-]mix-env Appends the mix environment used while building the release from the current branch or across all branches (default). Appending the commit count from the current branch makes more sense, if the branch name is also appended as metadata to avoid conflicts from different branches.

Version Modification

  • show Displays the current release version.
  • increment Increments the release version for the current build

    • patch Increments the patch version (default). The last part of a tripartite version.
    • minor Increments the minor version. The middle part of a tripartite version.
    • major Increments the major version. The first part of a tripartite version.
  • set <new-version> Sets the release version for the current build

Options

  • -V, --verbose Verbose output
  • -Q, --quiet Print only errors while modifying version
  • -D, --dry-run Print only new version without changing it

Environment Variables

  • AUTO_VERSION as long no arguments are passed directly which append metadata to the version (flags from the Append-Metadata section) the values from that env are used to append metadata.

Example

MIX_ENV=prod mix do clean, release.version append-git-revision, release

Link to this section Summary

Functions

Gets the current branch that will be built. Since the git repository on the build host is usually in a detatched state because a specific revision is checked out when building (see git_reset_remote() in libexec/common), this won't work

Gets the current number of commits across all branches

Gets the current number of commits in the current branch

Gets the current date in the form yyyymmdd

Gets the current revision of the git repository edeliver is used as deploy tool for. The sha1 hash containing 7 hexadecimal characters is returned.

Gets the current date in the form hhmmss

Gets the version which should be set as fixed version (instead of incrementing) from the args and returns the args without that value.

Modifies the current release version by applying the modification_funs which were collected while parsing the args. If there was an error parsing the arguments passed to this task, this function prints the error and exists the erlang vm, meaning aborting the mix task. If :show is returned from parsing the arguments, this function just prints the current release version.

Normalizes the arguments passed to this task. This is done by splitting arguments separated by a +, removing leading append- -git and -build strings and renaming commit-count to commit_count

Parses the arguments passed to this release.version task and merges them with the AUTO_VERSION environment variable. This arguments must not contain any output flags like -V or -Q.

Callback implementation for Mix.Task.run/1.

Sorts the args in that way, that all args incrementing or setting the version come first
and all args appending metadata come last by not changing their particular order.

Link to this section Types

Link to this type

modification_arg()

modification_arg() ::
  {modified_version :: String.t(), has_metadata :: boolean()}
Link to this type

modification_fun()

modification_fun() :: (modification_arg() -> modification_arg())

Link to this section Functions

Link to this function

get_branch()

get_branch() :: String.t()

Gets the current branch that will be built. Since the git repository on the build host is usually in a detatched state because a specific revision is checked out when building (see git_reset_remote() in libexec/common), this won't work:

git rev-parse --abbrev-ref HEAD

Instead

git branch --contains <revision> could be used. But the commit/revision can still be in several branches, e.g. if one branch containing that commit was built before and that branch is later merged and built again. Then the old branch exists still on the build host and the commit exists in both branches. So whenever possible we will pass the branch which is built as BRANCH env, but as fallback we try to autodetect the branch which contains the current commit that is built.

Link to this function

get_commit_count()

get_commit_count() :: String.t()

Gets the current number of commits across all branches

Link to this function

get_commit_count_branch()

get_commit_count_branch() :: String.t()

Gets the current number of commits in the current branch

Link to this function

get_date()

get_date() :: String.t()

Gets the current date in the form yyyymmdd

Link to this function

get_git_revision()

get_git_revision() :: String.t()

Gets the current revision of the git repository edeliver is used as deploy tool for. The sha1 hash containing 7 hexadecimal characters is returned.

Link to this function

get_time()

get_time() :: String.t()

Gets the current date in the form hhmmss

Link to this function

get_version_to_set_from_args(args, remaining_args)

get_version_to_set_from_args(
  args :: OptionParser.argv(),
  remaining_args :: OptionParser.argv()
) ::
  {version_to_set :: String.t() | nil,
   args_without_version :: OptionParser.argv()}

Gets the version which should be set as fixed version (instead of incrementing) from the args and returns the args without that value.

Link to this function

modify_version(arg1, version)

modify_version(
  {:modify, [modification_fun()]} | {:error, message :: String.t()} | :show,
  version :: String.t()
) :: :ok | :error | {:modified, new_version :: String.t()}

Modifies the current release version by applying the modification_funs which were collected while parsing the args. If there was an error parsing the arguments passed to this task, this function prints the error and exists the erlang vm, meaning aborting the mix task. If :show is returned from parsing the arguments, this function just prints the current release version.

Link to this function

modify_version_branch(arg)

Link to this function

modify_version_branch_unless_master(arg)

Link to this function

modify_version_commit_count(arg)

Link to this function

modify_version_commit_count_branch(arg)

Link to this function

modify_version_date(arg)

Link to this function

modify_version_major(arg)

Link to this function

modify_version_minor(arg)

Link to this function

modify_version_mix_env(arg)

Link to this function

modify_version_patch(arg)

Link to this function

modify_version_revision(arg)

Link to this function

modify_version_set(arg, version_to_set)

Link to this function

modify_version_time(arg)

Link to this function

normalize_args(args)

normalize_args(OptionParser.argv()) :: OptionParser.argv()

Normalizes the arguments passed to this task. This is done by splitting arguments separated by a +, removing leading append- -git and -build strings and renaming commit-count to commit_count

Link to this function

parse_args(args)

parse_args(OptionParser.argv()) ::
  :show | {:error, message :: String.t()} | {:modify, [modification_fun()]}

Parses the arguments passed to this release.version task and merges them with the AUTO_VERSION environment variable. This arguments must not contain any output flags like -V or -Q.

Callback implementation for Mix.Task.run/1.

Link to this function

sort_args_append_metadata_last(args, increment_version_args, append_metadata_args)

sort_args_append_metadata_last(
  args :: OptionParser.argv(),
  increment_version_args :: OptionParser.argv(),
  append_metadata_args :: OptionParser.argv()
) :: args :: OptionParser.argv()
Sorts the args in that way, that all args incrementing or setting the version come first
and all args appending metadata come last by not changing their particular order.
Link to this function

valid_semver_metadata(string)