Reputation: 35825
Gitflow introduces several branches like develop
, release
, hotfix
, and also encourages feature branches.
In a Maven project, you usually build SNAPSHOT and release versions, and often number them with semantic, three-digit versions.
It would be sensible to automate the build process as much as possible, but the question is: When should we build a SNAPSHOT version, when should be build a release version, when should we build none of that at all?
I image the following could be sensible:
develop
, a SNAPSHOT build is triggered and deployed to the Maven repository.release
branch is created, as release build is started.But there are much more situations:
release
(or hotfix
) branch, do I always want a new release build?1.2.3-FEATURE1-SNAPSHOT
?)?Upvotes: 2
Views: 1819
Reputation: 15308
Let's start with releases. Whether a version is going to be released or not is decided in the future when an already-built binary is deployed to TST envs and checked. When committing or building you can't predict whether the version will be a "release".
Once you abandon these ideas things will become much simpler. And since you can't use branch-based versions for releases, what's the point of making things different for feature branches? You might as well forget about mixing the concepts of branching and versioning together.
With Continuous Delivery (you can borrow its ideas even if you don't use it to the fullest) any build may potentially go to PRD, thus:
Also we usually want to mention from which commit the binary was built. You can put this into the binary (some kind of version.properties
) during the build time. You may even create an endpoint in your app that servers this version for convenience.
PS: if you simply want to follow GitFlow advice - there is an example of how you could version. But you'll have all the problems (and more) that you already mentioned in the question.
* Maven automatically resolves SNAPSHOT versions into timestamp-ones. But you can't actually use this functionality because the timestamp is going to be different for different artifcacts during the build. If you want to keep version the same across all the binaries in the build you need to generate and assign a timestamp version manually using versions:set
. It's not complicated, but is worth mentioning.
Upvotes: 4