How do I can increment project version number from my build.sbt file so that when you compile it automatically uploads to git?
The sbt-release plugin will do all of this for you.
If you issue the command sbt release from the command line, this plugin will remove the -SNAPSHOT suffix, tag, commit and push the changes to your repository, build, test and release the artifact, then update the version version number (adding the -SNAPSHOT suffix back again), committing the changes once more.
All of the above steps can be customized if necessary.
You can use the sbt-release plugin.
Steps
plugins.sbt file at specified location(./project/plugins.sbt) in your project.addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") plugin in plugins.sbt file.build.sbt file.import ReleaseTransformations._
releaseVersionBump := sbtrelease.Version.Bump.Next
releaseVersionFile := baseDirectory.value / "version.sbt"
publishConfiguration := publishConfiguration.value.withOverwrite(true)
releaseIgnoreUntrackedFiles := true
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies, // : ReleaseStep
inquireVersions, // : ReleaseStep
runClean, // : ReleaseStep
runTest, // : ReleaseStep
setReleaseVersion, // : ReleaseStep
commitReleaseVersion, // : ReleaseStep, performs the initial git checks
tagRelease, // : ReleaseStep
publishArtifacts, // : ReleaseStep, checks whether `publishTo` is properly set up
releaseStepTask(publish in Docker), // : ReleaseStep, publish the docker image in your specified repository(e.i. Nexus)
setNextVersion, // : ReleaseStep
commitNextVersion, // : ReleaseStep
pushChanges // : ReleaseStep, also checks that an upstream branch is properly configured
)
version.sbt file in the project's root directory.version in ThisBuild := "1.0.0-SNAPSHOT" in version.sbt file.sbt release or sbt 'release with-defaults')Note:
releaseStepTask(publish in Docker) in the ReleaseStep to automatically build/push docker images in your specified repository(e.i. Nexus).releaseStepTask(publish in Docker) step you need to add one sbt-native-packager(addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.6")) in plugins.sbt file.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With