I've been going at this for a while, and here's the current scenario:
- I have a development branch where after every push, I want to publish my current maven library as a SNAPSHOT. I currently do this by using exec-plugin and echo to retrieve my maven version (e.g.: -Dexec.executable=echo -Dexec.args='${project.version}' org.codehaus.mojo:exec-maven-plugin:1.6.0:exec))
- I then use the update-versions command to inject the "-SNAPSHOT" to it and publish (I don't publish it back to the branch, since I don't really want to keep the "-SNAPSHOT").
For release, I suppose I could do something similar where I retrieve the version, then figure out a way to increment it -> publish back to the currently active branch -> and then finally do a deploy. Right now, I went with a slightly easier although error-prone approach: I attempt to fetch the current version set in the artifactory we use and, if it exists, I fail the pipeline with a message stating that the version already exists. It's not great right now, because I'm actually inverting an error condition here, so if maven fails for any other reason, it actually assumes the version doesn't exist and keeps on going to the next steps. Ugh.
Now, the main points I was looking for here are really around the best method of handling maven projects and versioning. Ideally my goals are:
- be able to publish something as a SNAPSHOT properly (maybe without having to resort to maven-exec)?
- be able to update my version incrementally, so users don't have to constantly have to update their version? This process of course would have to ensure I don't push something to master that may have the wrong version (which would then fail at deploying). Edit: To rephrase, the intention here isn't just incrementing the version 'to the next one', but instead to the 'next available one', ensuring I don't try and merge a version that has been published before.
I do have one restriction: the tooling we use does not allow for us to have merge hooks (Azure DevOps with Azure Git). This means we are limited to pipelines on pulls (and PRs), and after a PR is merged.
I'm happy to take any other approach here realistically, I feel like I'm going out of my way to make something that should have a clear path by now, so I'm hoping for someone with some guidance here.