Skip to content

Commit

Permalink
Merge pull request #93 from softinio/add-circleci-support
Browse files Browse the repository at this point in the history
Added CircleCI support
  • Loading branch information
olafurpg authored Dec 28, 2019
2 parents abcdf41 + 6dc777f commit 20307e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
31 changes: 23 additions & 8 deletions plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import sbt._
import sbt.plugins.JvmPlugin
import sbtdynver.DynVerPlugin
import sbtdynver.DynVerPlugin.autoImport._
import scala.deprecated
import scala.sys.process._
import scala.util.control.NonFatal
import xerial.sbt.Sonatype
Expand All @@ -25,29 +26,44 @@ object CiReleasePlugin extends AutoPlugin {
override def requires =
JvmPlugin && SbtPgp && DynVerPlugin && GitPlugin && Sonatype

def isTravisSecure: Boolean =
def isSecure: Boolean =
System.getenv("TRAVIS_SECURE_ENV_VARS") == "true" ||
System.getenv("BUILD_REASON") == "IndividualCI" ||
System.getenv("PGP_SECRET") != null
def isTravisTag: Boolean =
def isTag: Boolean =
Option(System.getenv("TRAVIS_TAG")).exists(_.nonEmpty) ||
Option(System.getenv("CIRCLE_TAG")).exists(_.nonEmpty) ||
Option(System.getenv("BUILD_SOURCEBRANCH"))
.orElse(Option(System.getenv("GITHUB_REF")))
.exists(_.startsWith("refs/tags"))
def travisTag: String =
def releaseTag: String =
Option(System.getenv("TRAVIS_TAG"))
.orElse(Option(System.getenv("BUILD_SOURCEBRANCH")))
.orElse(Option(System.getenv("GITHUB_REF")))
.orElse(Option(System.getenv("CIRCLE_TAG")))
.getOrElse("<unknown>")
def travisBranch: String =
def currentBranch: String =
Option(System.getenv("TRAVIS_BRANCH"))
.orElse(Option(System.getenv("BUILD_SOURCEBRANCH")))
.orElse(Option(System.getenv("GITHUB_REF")))
.orElse(Option(System.getenv("CIRCLE_BRANCH")))
.getOrElse("<unknown>")

@deprecated("Deprecated, please use isSecure", "1.4.32")
def isTravisSecure: Boolean = isSecure
@deprecated("Deprecated, please use isTag", "1.4.32")
def isTravisTag: Boolean = isTag
@deprecated("Deprecated, please use releaseTag", "1.4.32")
def travisTag: String = releaseTag
@deprecated("Deprecated, please use currentBranch", "1.4.32")
def travisBranch: String = currentBranch

def isAzure: Boolean =
System.getenv("TF_BUILD") == "True"
def isGithub: Boolean =
System.getenv("GITHUB_ACTION") != null
def isCircleCi: Boolean =
System.getenv("CIRCLECI") == true

def setupGpg(): Unit = {
List("gpg", "--version").!
Expand Down Expand Up @@ -95,19 +111,19 @@ object CiReleasePlugin extends AutoPlugin {
publishArtifact.in(Test) := false,
publishMavenStyle := true,
commands += Command.command("ci-release") { currentState =>
if (!isTravisSecure) {
if (!isSecure) {
println("No access to secret variables, doing nothing")
currentState
} else {
println(
s"Running ci-release.\n" +
s" branch=$travisBranch"
s" branch=$currentBranch"
)
setupGpg()
// https://github.com/olafurpg/sbt-ci-release/issues/64
val reloadKeyFiles =
"; set pgpSecretRing := pgpSecretRing.value; set pgpPublicRing := pgpPublicRing.value"
if (!isTravisTag) {
if (!isTag) {
if (isSnapshotVersion(currentState)) {
println(s"No tag push, publishing SNAPSHOT")
reloadKeyFiles ::
Expand Down Expand Up @@ -146,5 +162,4 @@ object CiReleasePlugin extends AutoPlugin {
case None => throw new NoSuchFieldError("version")
}
}

}
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ coursier fetch com.geirsson:scalafmt-cli_2.12:1.5.0-SNAPSHOT -r sonatype:snapsho

### What about other CIs environments than Travis?

This project uses a github workflow, [which you can review here](https://github.com/olafurpg/sbt-ci-release/tree/master/.github/workflows)
- This project uses a github workflow, [which you can review here](https://github.com/olafurpg/sbt-ci-release/tree/master/.github/workflows)
- [CircleCI](https://circleci.com/) is supported

You can try
[sbt-release-early](https://github.com/scalacenter/sbt-release-early).
Expand Down

0 comments on commit 20307e5

Please sign in to comment.