How do you tag your release versions in git?
Now I have each release identified by build number, but they increment even if there are no changes in the repo. My idea is to have it generated automatically on successful deployment on staging server. E.g.
- run Hudson build
- when successful, add new tag, i.e. 1.0-1
- on next successful build add next tag, 1.0-2
- version tag is displayed then in site footer
This would require:
- Hudson to manage next version numbers
- or script to store last tag in some file
- or parse git tags to determine last
Any tips?
Really good solution timhc22 The only thing is that it takes the last tag (whatever the branch) If you work on a project with multiple branches you could have an issue. I proposed just an improvement with your base.
This works for example if you have:
In any case thanks a lot it helped me a lot.
I wrote this to help with updating tags incrementally e.g. 1.0.1 to 1.0.2 etc
I am using as below. It is working perfectly with branches. Below snippets inspired from above comments and the gitversion / semver.org.
What you are talking about is more akin to a technical revision number like the one a
git describe
would generate.That is different from a true application version, which you should still managed independently from Hudson since it depends on a versioning policy.
Hudson automatically tags the build, if you use the git plugin and let Hudson extract the code. I'm not sure if this gets pushed automatically; in our set up we do extra tagging and include a 'git push --tags' in our build script, so we definitely see the Hudson tags in our central repository.
In case if you will need Posix version, almost the same as above answer