diff --git a/.travis.yml b/.travis.yml index d010fd2..32b5063 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ cache: - "$HOME/.ivy2" script: - sbt ++$TRAVIS_SCALA_VERSION clean coverage scalafmtTest test -- if [ $TRAVIS_TEST_RESULT -eq 0 -a "$TRAVIS_PULL_REQUEST" = "false" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[A-Za-z0-9]+)?$ ]]; then +- if [ $TRAVIS_TEST_RESULT -eq 0 -a "$TRAVIS_PULL_REQUEST" = "false" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then echo "** Publishing Release $TRAVIS_TAG **" && tar xf secrets.tar && mkdir ~/.bintray && cp publishing/.credentials ~/.bintray/ diff --git a/build.sbt b/build.sbt index ea83e9e..e32014c 100644 --- a/build.sbt +++ b/build.sbt @@ -71,16 +71,19 @@ lazy val commonSettings = * ELSE the version is "0.0.0-commitHash-SNAPSHOT" */ val VersionRegex = "v([0-9]+.[0-9]+.[0-9]+)-?(.*)?".r +val MilestoneRegex = "^M[0-9]$".r lazy val versioningSettings = Seq( git.baseVersion := "0.0.0", git.useGitDescribe := true, git.gitTagToVersionNumber := { - case VersionRegex(v, "") => Some(v) - case VersionRegex(v, s) if s.startsWith("M") => Some(s"$v-$s") - case VersionRegex(v, "SNAPSHOT") => Some(s"$v-SNAPSHOT") - case VersionRegex(v, s) => Some(s"$v-$s-SNAPSHOT") - case _ => None + case VersionRegex(v, "") => Some(v) //e.g. 1.0.0 + case VersionRegex(v, s) + if MilestoneRegex.findFirstIn(s).isDefined => Some(s"$v-$s") //e.g. 1.0.0-M1 + case VersionRegex(v, s) + if s.endsWith("SNAPSHOT") => Some(s"$v-SNAPSHOT") //e.g. 1.0.0-SNAPSHOT + case VersionRegex(v, s) => Some(s"$v-$s-SNAPSHOT") //e.g. 1.0.0-2-commithash-SNAPSHOT + case _ => None } ) diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..f9208a0 --- /dev/null +++ b/test.sh @@ -0,0 +1,34 @@ +if [[ "v1.2.3-SNAPSHOT" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then + echo "** Matched v1.2.3-SNAPSHOT **" +else + echo "Didn't match v1.2.3-SNAPSHOT"; fi + +if [[ "v1.2.3" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then + echo "** Matched v1.2.3 **" +else + echo "Didn't match v1.2.3"; fi + + +if [[ "1.2.3" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then + echo "** Matched 1.2.3 **" +else + echo "Didn't match 1.2.3"; fi + + +if [[ "v1.2.3-M1" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then + echo "** Matched v1.2.3-M1 **" +else + echo "Didn't match v1.2.3-M1"; fi + +if [[ "v1.2.3-M1-SNAPSHOT" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then + echo "** Matched v1.2.3-M1-SNAPSHOT **" +else + echo "Didn't match v1.2.3-M1-SNAPSHOT"; fi + +if [[ "v1.2.3-X1" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-M[0-9]+)?$ ]]; then + echo "** Matched v1.2.3-X1 **" +else + echo "Didn't match v1.2.3-X1"; fi + + +