Skip to content

Commit

Permalink
Merge pull request #170 from mdedetrich/calculate-snapshot-version-pr…
Browse files Browse the repository at this point in the history
…operly

Calculate snapshot version properly
  • Loading branch information
mdedetrich authored Oct 23, 2023
2 parents fdcdd45 + f8ed0c6 commit 693adf3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,21 @@ ThisBuild / githubWorkflowPublish := Seq(
)
)
)
ThisBuild / version := {
val orig = (ThisBuild / version).value
if (orig.endsWith("-SNAPSHOT")) orig.split("""\+""").head + "-SNAPSHOT"
else orig

// So that publishLocal doesn't continuously create new versions
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val snapshotSuffix = if
(out.isSnapshot()) "-SNAPSHOT"
else ""
out.ref.dropPrefix + snapshotSuffix
}

def fallbackVersion(d: java.util.Date): String = s"HEAD-${sbtdynver.DynVer timestamp d}"

ThisBuild / version := dynverGitDescribeOutput.value.mkVersion(versionFmt, fallbackVersion(dynverCurrentDate.value))
ThisBuild / dynver := {
val d = new java.util.Date
sbtdynver.DynVer.getGitDescribeOutput(d).mkVersion(versionFmt, fallbackVersion(d))
}

sbtPlugin := true
Expand Down

0 comments on commit 693adf3

Please sign in to comment.