4

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?

asked May 19, 2016 at 14:22

1 Answer 1

2

Not really, if the source code is obtained from the tagged branch, then its obvious which version is which!

You may have more difficulty if you're working on a branch, which is probably taken from trunk, or one taken from a tag so you won't necessarily know which version the source corresponds to. If you can find the version the source came from, then its no problem. IF you can't, then your devs just have to be a bit more careful. If your devs are sloppy then a file with the version number might help them but you probably have bigger problems in that case.

One place where you might want to include a version number in source is in a readme or changelog. Some people update this by hand (summarising changes) or generate it from your SCM, but I feel its still best to commit it to the source directory once its created as part of a build. If you do this, you will have the version number right at the top no matter which source branch you fetch.

answered May 19, 2016 at 14:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.