Automatic mercurial tagging
Welcome to my tag revision script written in Perl. I have used it to keep track of my beta versions distributed with the Hockey framework.
What can it do for you ?
You can use this script to track your version numbers especially in the beta development phase. It does so by using mercurial's tag feature to tag the revision with the version string and also updating the version in the Info.plist file. This is neccessary because only higher version numbers can be installed over existing ones. //
To make it easier to use it can be used from Xcodes build system. Just choose your special "build beta version" target, build&archive it and you can directly choose to distribute it via the Hockey framework without having to take care of the version numbers.
If you like it, find it useful or have any ideas about improvements or issues, please use the issue tracker or drop me a tweet Thomas Westfeld .
- Automatically tags revisions with the next highest version nubmer
- Makes sure that there are no uncommited changes present before tagging to ensure data integrity
- Checks if this revision already has been tagged, does not tag the same revision twice even if built twice.
Install the script
- Add the script file "tagRevision.pl" to your project and add it to your mercurial repository. Note: Consider making a "Scripts" folder to keep your code organized.
- Edit the script of the new build phase as shown here. Make sure the path to the script is correct. In this case there is a "Scripts" subdirectory in the projects directory. Note: Line 2 and 3 are neccessary to pass the return code of the perl script to the build system.
Edit the target
- Add a "Run Script Phase" to your target you want to track the version number of. Add it after the "Link Binary With Library" phase as shown here. Note: It is beneficial to have separate Info.plist files and bundle identifier for development, ad-hoc distribution and app store distribution.
- Add at least the two user-defined settings to the target's build settings. Use the "MERCURIAL_EXECUTABLE" variable to specify the full path to the hg binary and set the "VERSION_PREFIX" variable to the fixed part of your version number. Make sure it ends with a trailing "." .
|VERSION_PREFIX setting||Generated version numbers|
|1.||1.0 1.1 1.2 1.2 etc.|
|1.2.||1.2.0 1.2.1 1.2.2 etc|
Edit your Xcode preferences
- Deselect the "Continue after errors" checkbox in the build settings to make sure only builds that build without an error are tagged.
How to use it
Whenever you want to make a new version you chose the active target to be the one which executes the script. If there are uncommited changes, the build will fail and give an error message in the build results. If the tagging was successful there will be a message that the version was tagged.
You can build this target multiple times. As long as there are no changes in the repository it will not be tagged again.
Copyright 2010 Thomas Westfeld (Thomas Westfeld on twitter)