Skip to content

Commit

Permalink
Use environment variable to initialize isRelease.
Browse files Browse the repository at this point in the history
Previously we were only releasing SNAPSHOTs.
  • Loading branch information
non committed Sep 25, 2019
1 parent 93159bf commit ad11e73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions build.sbt
Expand Up @@ -6,9 +6,12 @@ scalaVersionSettings

lazy val versionNumber = "1.14.2"

val isRelease = SettingKey[Boolean]("isRelease")
def env(name: String): Option[String] =
Option(System.getenv(name))

lazy val travisCommit = Option(System.getenv().get("TRAVIS_COMMIT"))
val isRelease = env("IS_RELEASE").exists(_ == "true")

lazy val travisCommit = env("TRAVIS_COMMIT")

lazy val scalaVersionSettings = Seq(
scalaVersion := "2.13.1",
Expand All @@ -22,22 +25,20 @@ lazy val scalaVersionSettings = Seq(
)

lazy val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.29")
env("SCALAJS_VERSION").getOrElse("0.6.29")

lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(

name := "scalacheck",

isRelease := false,

version := {
val suffix =
if (isRelease.value) ""
if (isRelease) ""
else travisCommit.map("-" + _.take(7)).getOrElse("") + "-SNAPSHOT"
versionNumber + suffix
},

isSnapshot := !isRelease.value,
isSnapshot := !isRelease,

organization := "org.scalacheck",

Expand All @@ -46,8 +47,8 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
homepage := Some(url("http://www.scalacheck.org")),

credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
username <- env("SONATYPE_USERNAME")
password <- env("SONATYPE_PASSWORD")
} yield Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
Expand Down Expand Up @@ -127,7 +128,7 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
publishMavenStyle := true,

// Travis should only publish snapshots
publishArtifact := !(isRelease.value && travisCommit.isDefined),
publishArtifact := !(isRelease && travisCommit.isDefined),

publishArtifact in Test := false,

Expand Down
4 changes: 2 additions & 2 deletions release.sh
Expand Up @@ -30,10 +30,10 @@ usage() {
}

runsbt() {
sbt "$1"
IS_RELEASE="true" sbt "$1"
RES=$?
if [ $RES -ne 0 ]; then
echo "sbt 'set every isRelease := true' '$1' failed: $RES"
echo "sbt '$1' failed: $RES"
exit $RES
fi
}
Expand Down

0 comments on commit ad11e73

Please sign in to comment.