edeliver_fork v1.4.5 Mix.Tasks.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-][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 buildpatch
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
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 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_fun
s 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
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
Types
modification_arg :: {modified_version :: String.t, has_metadata :: boolean}
Functions
Specs
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.
Specs
get_commit_count :: String.t
Gets the current number of commits across all branches
Specs
get_commit_count_branch :: String.t
Gets the current number of commits in the current branch
Specs
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.
Specs
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.
Specs
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_fun
s 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.
Specs
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
Specs
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
.
Specs
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.