Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt-git and sbt-native-packager #125

Closed
magegu opened this issue Jan 8, 2014 · 5 comments
Closed

sbt-git and sbt-native-packager #125

magegu opened this issue Jan 8, 2014 · 5 comments

Comments

@magegu
Copy link

magegu commented Jan 8, 2014

hi guys,

for easier distribution and testing I would like to see the git commit SHA added to the debian version string. I added the sbt-git plugin but the deb version keeps untouched while the play:dist task builds a git-versioned zip file (so i assume the plugin itself is working). To push new deb archives i'll now have to change the version number which is a bit annoying for continues systems.

Martin

@kardapoltsev
Copy link
Member

You could add date or timestamp to version in build definition e.g.

val appVersion = "0.2" + System.currentTimeMilis().toString

@hfs
Copy link
Contributor

hfs commented Jan 31, 2014

I've done it like this in build.sbt (without sbt-git):

version := "0.2-SNAPSHOT"

// If the version ends with "-SNAPSHOT", let the Debian version end with
// "~SNAPSHOT~yyyyMMddHHmmss". This way updates of the snapshot version can be
// detected by the package manager. Also the tilde "~" sorts before anything
// else when comparing version numbers. This way "1.0" will be regarded newer
// than "1.0~beta".
version in Debian <<= (version) { (v) =>
    if (v.endsWith("-SNAPSHOT")) {
       val timestampFormat = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
       timestampFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
       val now = timestampFormat.format(new java.util.Date());
       v.replace("-SNAPSHOT", "~SNAPSHOT~" + now)
    } else {
       v
    }
}

@muuki88
Copy link
Contributor

muuki88 commented Jan 31, 2014

Thanks for sharing. If you figure out a way with sbt-git let me know. This would be even better.

@hfs
Copy link
Contributor

hfs commented Feb 5, 2014

I’ve tried it with sbt-native-packager 0.7.0-M2 and sbt-git 0.6.2 and for me it just works as advertised? I’ve put this in my build.sbt according to the instructions:

import com.typesafe.sbt.SbtGit._

versionWithGit

git.baseVersion := "0.1"

If the head revision is not tagged the commit hash is appended to the version of the .deb, too. If it is tagged the version from the tag is used.

@muuki88
Copy link
Contributor

muuki88 commented Mar 12, 2014

I can reproduce what @hfs did. Take care that you don't have any version := "x.y" settings in your build.sbt

@muuki88 muuki88 closed this as completed Mar 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants