I want to automatically set version number to my program in such way they are consistent with git tags. How this could be done? And what is the suggested way of doing this?
Example
The following highly sophisticated python script prints its version number. How should I automatically update that version number each time I commit something?
# application.py
hardcoded_version_number = "0"
print("v"+hardcoded_version_number)
After each commit version number should be updated.
release 0.1 / initial commit:
hardcoded_version_number = "0.1"
print("v"+hardcoded_version_number)
feature 1:
hardcoded_version_number = "0.1-1-gf5ffa14" # or something like this
print("v"+hardcoded_version_number)
release 0.2:
hardcoded_version_number = "0.2"
print("v"+hardcoded_version_number)
etc...
Another problem I have currently is that GUI element I'm using can't read version number from any external sources during runtime. So only option I have is to hardcode it.