This is a set of scripts that I use for automatically tagging, and generating version/build metadata for, mercurial and git projects. They provide your automation with quite a bit of information about the version being built, where it is built, and who built it. They also generate automatic changelogs for you.
*PRIMARILY, THIS ASSUMES YOU ARE USING A BASH SCRIPT-CAPABLE BUILD ENVIRONMENT. THESE ARE BASH SCRIPTS.*
This assumes you want your project versioned like this:
(MAJOR)-(BUILD)
... Where MAJOR will default to the name of the current branch, or the value of MAJOR on the previous tag (of the current branch). BUILD will default to 0, or the BUILD of the last tag (on the current branch) plus one.
If you want your project to use a MAJOR that is NOT equal to the branch name (e.g. you want branch 'master' to be '1.1'), then you must set an initial tag on that branch, e.g:
Two scripts, 'gitversion.sh' and 'hgversion.sh' generate version metadata for git and hg, respectively. The data output by these two is meant to be consumed by bash.
This can be piped into a bash script for later sourcing. You can source this into a variety of other languages as well (python or ruby), but the ${:-} syntax is bash specific, and might confuse other languages.