-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Akka 2.9.3-M3 and publish to Akka repo (#773)
- Loading branch information
Showing
6 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2023 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean | ||
|
||
import scala.language.postfixOps | ||
|
||
import sbt.{ Def, _ } | ||
import Keys._ | ||
import com.geirsson.CiReleasePlugin | ||
import com.jsuereth.sbtpgp.PgpKeys.publishSigned | ||
import xerial.sbt.Sonatype.autoImport.sonatypeProfileName | ||
|
||
/** | ||
* For projects that are not published. | ||
*/ | ||
object NoPublish extends AutoPlugin { | ||
override def requires = plugins.JvmPlugin | ||
|
||
override def projectSettings = | ||
Seq(publish / skip := true, publishArtifact := false, publish := {}, publishLocal := {}) | ||
} | ||
|
||
object Publish extends AutoPlugin { | ||
override def requires = plugins.JvmPlugin && ProjectAutoPlugin | ||
override def trigger = AllRequirements | ||
|
||
lazy val beforePublishTask = taskKey[Unit]("setup before publish") | ||
|
||
lazy val beforePublishDone = new AtomicBoolean(false) | ||
|
||
def beforePublish(snapshot: Boolean) = { | ||
if (beforePublishDone.compareAndSet(false, true)) { | ||
CiReleasePlugin.setupGpg() | ||
if (!snapshot) | ||
cloudsmithCredentials(validate = true) | ||
} | ||
} | ||
|
||
override def projectSettings: Seq[Def.Setting[_]] = Seq( | ||
sonatypeProfileName := "com.lightbend", | ||
beforePublishTask := beforePublish(isSnapshot.value), | ||
publishSigned := publishSigned.dependsOn(beforePublishTask).value, | ||
publishTo := (if (isSnapshot.value) | ||
Some(Resolver.file("file", target.value / "repository")) // FIXME snapshot repo | ||
else | ||
Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka/"))), | ||
credentials ++= (if (isSnapshot.value) Seq[Credentials]() else cloudsmithCredentials(validate = false))) | ||
|
||
def cloudsmithCredentials(validate: Boolean): Seq[Credentials] = { | ||
(sys.env.get("PUBLISH_USER"), sys.env.get("PUBLISH_PASSWORD")) match { | ||
case (Some(user), Some(password)) => | ||
Seq(Credentials("Cloudsmith API", "maven.cloudsmith.io", user, password)) | ||
case _ => | ||
if (validate) | ||
throw new Exception("Publishing credentials expected in `PUBLISH_USER` and `PUBLISH_PASSWORD`.") | ||
else | ||
Nil | ||
} | ||
} | ||
} |