Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
added support for milestones
Browse files Browse the repository at this point in the history
  • Loading branch information
markglh committed May 1, 2017
1 parent af72cfe commit a065bc0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
13 changes: 8 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)

Expand Down
34 changes: 34 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -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



0 comments on commit a065bc0

Please sign in to comment.