Mix has the notion of versions built into it. If you open up a mix file you’ll see a line like below:
If you are using Git, there is a simple way to automatically generate a meaningful semantic version. All you need to do is:
- Tag a commit with a version tag, like below:
- Put a helper function which can use this info with
git describeto generate a version
- Use the return value from this function as the version
The way this works is simple. From the man pages of git-describe
NAME git-describe - Describe a commit using the most recent tag reachable from it
DESCRIPTION The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit.
So, if you have a tag
v1.0 like above, and if you have 10 commits on top of it,
git-describe will print
v1.0 is the latest git tag reachable from the
100 is the number of commits since then and
g1c7ef8b is the short commit hash of the current commit. We can easily transform this to
1.0.100 using the above helper function.
Now, you have a nice way of automatically managing versions. The patch version is bumped whenever a commit is made, the major and minor version can be changed by creating a new tag, e.g.
This is very useful when you are using distillery for building your releases