Reputation: 593
Our startup has about 5 scala projects for which we frequently need to push updates to production. Because of our rapid pace, I quickly found the sbt release plugin to be too much overhead and thus have been pushing SNAPSHOTS out throughout the day. We have a build server (Jenkins) in the cloud - that could be used to generate releases as well, but even this slows us down.
Are there any good plugins that can do something like grab the git checkout hash and user that (along with a date) as the version?
Upvotes: 4
Views: 908
Reputation: 11280
Thanks to sbt's Process API, you actually need very little to include the git hash in your version:
version in ThisBuild := "1.0-" + Process("git rev-parse HEAD").lines.head
Use git rev-parse --short HEAD
for the short version of a git hash.
Of course for better reuse, you could move the Process
part into its own setting and just do something like:
version in ThisBuild <<= gitSha("1.0-" + _)
Upvotes: 6
Reputation: 74619
tl;dr Use sbt-git plugin.
Do enablePlugins(GitVersioning)
in build.sbt
of a module and start auto-generate your version using the plugin.
Upvotes: 2