Question

I was explaining a proposed build system (Gradle/Artifactory/Jenkins/Chef) to one of our senior architects, and he made a comment to me that I sort of disagree with, but am not experienced enough to really weigh-in on.

This project builds a Java library (JAR) as an artifact to be reused by other teams. For versioning, I'd like to use the semantic approach of:

<major>.<minor>.<patch>

Where patch indicates bug/emergency fixes, minor indicates backwards-compatible releases, and major indicates either massive refactorings of the API and/or backwards-incompatible changes.

As far as delivery goes here is what I want: a developer commits some code; this triggers a build to a QA/TEST environment. Some tests are ran (some automated, some manual). If all tests pass, then a production build publishes the JAR to our in-house repo. By this point the JAR should be versioned properly, and my thinking was to use the build.number that is automatically generated and provided by our CI tool to act as the patch number.

Thus, the versioning would actually be:

<major>.<minor>.<build.number>

Again, where build.number is provided by the CI tool.

The architect dismissed this, saying that using the CI build number was an "abuse" of semantic versioning.

My question is: is this correct, and if so, why? And if not, why not?

Was it helpful?

Solution

Your build number won't be reset to 0, when minor and major versions increase, this violates sections 7 and 8 of the specs:

Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backwards compatible functionality is introduced to the public API. It MUST be incremented if any public API functionality is marked as deprecated. It MAY be incremented if substantial new functionality or improvements are introduced within the private code. It MAY include patch level changes. Patch version MUST be reset to 0 when minor version is incremented.

Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API. It MAY include minor and patch level changes. Patch and minor version MUST be reset to 0 when major version is incremented.

So, version numbers (major, minor, patch) must be provided manually, as these are used to tell your users about changes in one place without them having to look at your changelog or some other document.

If you want to include your build number, then you may append them after a + (section 10):

Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Build metadata SHOULD be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85.

OTHER TIPS

One reason is that the patch may require several builds, so if you have version 5.7, and you want to patch it to 5.7.1, but your first 2 bugfixes fail to build when they are submitted to the CI system, then you will be at 5.7.3 before you've released your first patch!

The answer is to simply use 4 digits (as Microsoft systems tend to have). The 4th is a build number and is used "for information only". Generally people put the repository version number in there (if they use SVN or TFS or similar) which is really nice as you can verify which exact commit was used to build the binaries. If you don't have such a thing, then the CI build number is a reasonable approximation (as you'd hope your CI system can remember the build numbers and tie it to the repo history, but you're not reliant on the CI system remembering them - you can never delete old builds).

One thing to note, The Microsoft schema for versioning uses the 3rd position for build numbers. Chrome uses just 1 number. Ubuntu uses the date. There is no "standard" to use, except that all numbers must increment.

Licensed under: CC-BY-SA with attribution
scroll top