Currently to create releases for our project, we're using
Travis CI to upload binaries whenever a tag is
created.
We're using semantic versioning, so our tags have the form v<Major>.<Minor>.<Patch>
. Our version number is set by CMake, and to
avoid problems with it getting out of sync with the tag version number, we're
using a simple script to extract the version number from the TRAVIS_TAG
environment variable.
Our CMakeLists.txt
looks something like this:
execute_process(COMMAND .travis/get_version_from_tag.sh major OUTPUT_VARIABLE MAJOR)
execute_process(COMMAND .travis/get_version_from_tag.sh minor OUTPUT_VARIABLE MINOR)
execute_process(COMMAND .travis/get_version_from_tag.sh patch OUTPUT_VARIABLE PATCH)
set(VERSION ${MAJOR}.${MINOR}.${PATCH})
# Using the version number later for packaging, etc...
set(CPACK_PACKAGE_MAJOR ${MAJOR})
set(CPACK_PACKAGE_MINOR ${MINOR})
set(CPACK_PACKAGE_PATCH ${PATCH})
INCLUDE(CPack)
I like this approach because it makes it very easy to publish releases, and there's no risk of forgetting to update the hard-coded version number in a file somewhere. On the other hand, I'm worried it might be a bit confusing since from a copy of the source code alone, it's impossible to know the version number.
Is this an overly complicated and confusing setup?