From eb110888c61579210fa0ef54f68bdf32f7664a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Mon, 11 Jun 2018 11:24:59 +0200 Subject: [PATCH] Back to inScope(Global) --- build.sbt | 7 ++++++ .../scala/com/geirsson/CiReleasePlugin.scala | 2 -- readme.md | 25 ++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 7a8c977..710cc86 100644 --- a/build.sbt +++ b/build.sbt @@ -33,3 +33,10 @@ lazy val plugin = project addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3"), addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") ) + +// For some reason, it doesn't work if this is defined in buildSettings in CiReleasePlugin. +inScope(Global)( + Seq( + PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray()) + ) +) diff --git a/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala b/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala index a5dc084..5694d59 100644 --- a/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala +++ b/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala @@ -1,6 +1,5 @@ package com.geirsson -import com.typesafe.sbt.pgp.PgpKeys import sbtdynver.DynVerPlugin.autoImport._ import sbt.Def import sbt._ @@ -24,7 +23,6 @@ object CiReleasePlugin extends AutoPlugin { } override def buildSettings: Seq[Def.Setting[_]] = List( - PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray()), dynverSonatypeSnapshots := true ) diff --git a/readme.md b/readme.md index e814541..c729e39 100644 --- a/readme.md +++ b/readme.md @@ -48,7 +48,7 @@ Next, define publishing settings at the top of `build.sbt` inThisBuild(List( organization := "com.geirsson", homepage := Some(url("/~https://github.com/scalameta/sbt-scalafmt")), - licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), + licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), developers := List( Developer( "olafurpg", @@ -60,6 +60,16 @@ inThisBuild(List( )) ``` +Next, copy-paste the following to the bottom of `build.sbt` + +```scala +inScope(Global)(List( + PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray()) +)) +``` +(NOTE. I tried to automatically define `PGP_PASSPHRASE` in `sbt-ci-release` but it doesn't seem to work) + + Next, create a fresh gpg key that you will share with Travis CI and only use for this project. @@ -211,3 +221,16 @@ 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. + +### CI freezes on "Please enter PGP passphrase (or ENTER to abort):" + +Make sure you define the following settings in the top-level of your `build.sbt` +```scala +inScope(Global)(List( + PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray()) +)) +``` +NOTE. It doesn't seem possible to define this setting outside of `build.sbt`, I've tried +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!