Skip to content

Commit

Permalink
Publish only the -SNAP docker tag for snapshot sbt dockerBuildAndPush.
Browse files Browse the repository at this point in the history
  • Loading branch information
kshakir committed Feb 15, 2019
1 parent d6038cf commit 6e1171d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions project/Publishing.scala
Expand Up @@ -22,16 +22,17 @@ object Publishing {
versions.
`sbt 'show docker::imageNames'` returns:
ArrayBuffer(broadinstitute/womtool:30, broadinstitute/womtool:30-c33be41-SNAP)
ArrayBuffer(broadinstitute/cromwell:30, broadinstitute/cromwell:30-c33be41-SNAP)
ArrayBuffer(broadinstitute/womtool:30-c33be41-SNAP)
ArrayBuffer(broadinstitute/cromwell:30-c33be41-SNAP)
`CROMWELL_SBT_DOCKER_TAGS=dev,develop sbt 'show docker::imageNames'` returns:
ArrayBuffer(broadinstitute/womtool:dev, broadinstitute/womtool:develop)
ArrayBuffer(broadinstitute/cromwell:dev, broadinstitute/cromwell:develop)
*/
dockerTags := sys.env
.getOrElse("CROMWELL_SBT_DOCKER_TAGS", s"$cromwellVersion,${version.value}")
.split(","),
dockerTags := {
val versionsCsv = if (Version.isSnapshot) version.value else s"$cromwellVersion,${version.value}"
sys.env.getOrElse("CROMWELL_SBT_DOCKER_TAGS", versionsCsv).split(",")
},
imageNames in docker := dockerTags.value map { tag =>
ImageName(namespace = Option("broadinstitute"), repository = name.value, tag = Option(tag))
},
Expand Down
11 changes: 8 additions & 3 deletions project/Version.scala
Expand Up @@ -7,6 +7,14 @@ object Version {
// Upcoming release, or current if we're on a master / hotfix branch
val cromwellVersion = "38"

/**
* Returns true if this project should be considered a snapshot.
*
* The value is read in directly from the system property `project.isSnapshot` as there were confusing issues with
* the multi-project and sbt.Keys#isSnapshot().
*/
val isSnapshot = sys.props.get("project.isSnapshot").forall(_.toBoolean)

// Adapted from SbtGit.versionWithGit
def cromwellVersionWithGit: Seq[Setting[_]] =
Seq(
Expand Down Expand Up @@ -71,9 +79,6 @@ object Version {
//Now we fall through the potential version numbers...
val version = overrideVersion orElse commitVersion getOrElse unknownVersion

// The project isSnapshot string passed in via command line settings, if desired.
val isSnapshot = sys.props.get("project.isSnapshot").forall(_.toBoolean)

// For now, obfuscate SNAPSHOTs from sbt's developers: https://github.com/sbt/sbt/issues/2687#issuecomment-236586241
if (isSnapshot) s"$version-SNAP" else version
}
Expand Down

0 comments on commit 6e1171d

Please sign in to comment.