Skip to content

Commit

Permalink
Back to inScope(Global)
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Jun 11, 2018
1 parent 7f942de commit eb11088
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
7 changes: 7 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
)
)
2 changes: 0 additions & 2 deletions plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.geirsson

import com.typesafe.sbt.pgp.PgpKeys
import sbtdynver.DynVerPlugin.autoImport._
import sbt.Def
import sbt._
Expand All @@ -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
)

Expand Down
25 changes: 24 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.

Expand Down Expand Up @@ -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!

0 comments on commit eb11088

Please sign in to comment.