From bef95d465f07abdf7297fe66e177802156c7e17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Tue, 12 Jun 2018 10:17:27 +0200 Subject: [PATCH] Refactor code and docs --- .../scala/com/geirsson/CiReleasePlugin.scala | 18 +++++-------- readme.md | 25 ++++++++++++++++++- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala b/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala index 5694d59..41cf778 100644 --- a/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala +++ b/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala @@ -17,20 +17,14 @@ object CiReleasePlugin extends AutoPlugin { def isTravisSecure: Boolean = System.getenv("TRAVIS_SECURE_ENV_VARS") == "true" - private def env(key: String): String = - Option(System.getenv(key)).getOrElse { - throw new NoSuchElementException(s"""sys.env("$key")""") - } + def setupGpg(): Unit = { + (s"echo ${sys.env("PGP_SECRET")}" #| "base64 --decode" #| "gpg --import").! + } override def buildSettings: Seq[Def.Setting[_]] = List( dynverSonatypeSnapshots := true ) - def setupGpg(): Unit = { - println("Setting up gpg") - (s"echo ${env("PGP_SECRET")}" #| "base64 --decode" #| "gpg --import").! - } - override def globalSettings: Seq[Def.Setting[_]] = List( publishMavenStyle := true, commands += Command.command("ci-release") { s => @@ -40,9 +34,9 @@ object CiReleasePlugin extends AutoPlugin { } else { println( s"Running ci-release.\n" + - s" TRAVIS_SECURE_ENV_VARS=${env("TRAVIS_SECURE_ENV_VARS")}\n" + - s" TRAVIS_BRANCH=${env("TRAVIS_BRANCH")}\n" + - s" TRAVIS_TAG=${env("TRAVIS_TAG")}" + s" TRAVIS_SECURE_ENV_VARS=${sys.env("TRAVIS_SECURE_ENV_VARS")}\n" + + s" TRAVIS_BRANCH=${sys.env("TRAVIS_BRANCH")}\n" + + s" TRAVIS_TAG=${sys.env("TRAVIS_TAG")}" ) setupGpg() if (!isTravisTag) { diff --git a/readme.md b/readme.md index 2818429..b9dd529 100644 --- a/readme.md +++ b/readme.md @@ -178,6 +178,19 @@ Even if it takes 10 attempts to get it right, it's still worth it because it's so nice to have automatic CI releases. +## Alternatives + +There exist great alternatives to sbt-ci-release that may work better for your setup. + +- [sbt-release-early](https://github.com/scalacenter/sbt-release-early): additionally supports publishing to Bintray and + other CI environments than Travis. +- [sbt-rig](https://github.com/Verizon/sbt-rig): additionally supporting publishing code + coverage reports, managing test dependencies and publishing docs. + +The biggest difference between these and sbt-ci-release wrt to publishing +is the base64 encoded `PGP_SECRET` variable. +I never managed to get the encrypted files and openssl working. + ## FAQ ### How do I publish sbt plugins? @@ -216,7 +229,9 @@ coursier fetch com.geirsson:scalafmt-cli_2.12:1.5.0-SNAPSHOT -r sonatype:snapsho ### What about other CIs environments than Travis? -The source code for sbt-ci-release is only ~50 loc, see +You can try [sbt-release-early](https://github.com/scalacenter/sbt-release-early). + +Alternatively, the source code for sbt-ci-release is only ~50 loc, see [CiReleasePlugin.scala](https://github.com/olafurpg/sbt-ci-release/blob/master/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala). You can copy-paste it to `project/` of your build and tweak the settings for your environment. @@ -240,3 +255,11 @@ NOTE. It doesn't seem possible to define this setting outside of `build.sbt`, I' overriding `globalSettings` and `buildSettings` in auto-plugins but it doesn't work. This setting needs to appear in every `build.sbt`. Let me know if you find a better workaround! + +### How do I disable publishing in certain projects? + +Add the following to the project settings (works only in sbt 1) + +```scala +skip in publish := true +```