Hi Ben, several years ago I created jgitver <https://jgitver.github.io> to cover such a use case and even more.
It uses git information (tags, branches, commits, metadatas, ...) to automatically compute a version based on configurable rules. So like you I can simply do: `git tag X.Y.Z && mvn deploy` jgitver <https://jgitver.github.io> brings more features & configuration capabilities without never modifying the pom files (like `mvn versions -dnewVersion` does). It is a solution among others but it is worthwhile trying it. An issue with solutions like yours is reproducibility : `git checkout X.Y.Z && mvn install`will not build again artifact-X.Y.Z ; but this can be considered minor depending on the use cases & needs. FYI here are the projects I maintain related to the topic: - jgitver library: https://github.com/jgitver/jgitver - jgitver maven extension: https://github.com/jgitver/jgitver-maven-plugin - jgitver gradle plugin: https://github.com/jgitver/gradle-jgitver-plugin Regards, Matthieu On Wed, Jul 31, 2019 at 5:51 PM Ben Podgursky <bpodgur...@gmail.com> wrote: > I've been experimenting with setting up Maven Central publishing from a > TravisCI build (since it's free for my OSS GitHub project), and I ended up > with a pattern that I think is pretty nice to work with (I've struggled > with the maven-deploy-plugin in the past). > > I've written it up here > > https://bpodgursky.com/2019/07/31/using-travisci-to-deploy-to-maven-central-via-git-tagging-aka-death-to-commit-clutter/ > but > tl,dr, the key thing I haven't seen used widely is the use of tags to > define release versions, eg: > > ``` > if [ ! -z "$TRAVIS_TAG" ] > then > mvn --settings "${TRAVIS_BUILD_DIR}/.travis/mvn-settings.xml" > org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=$TRAVIS_TAG > 1>/dev/null 2>/dev/null > else > echo "No tags, using snapshot version from pom.xml" > fi > > mvn deploy -P publish -DskipTests=true --settings > "${TRAVIS_BUILD_DIR}/.travis/mvn-settings.xml" > ``` > > This lets me cut a central release by just pushing a tag: > > ``` > $ git tag 1.23 > $ git push origin 1.23 > ``` > > I've used Maven a fair amount but I wouldn't consider myself perfectly in > tune with best practices, so I'm curious what others think of this > approach, or if there are other streamlined central deploy setups > (especially from CI/Travis) that I missed. > > > Thanks, > > Ben >