From c9e3eac3bbda4868597da2bcde5620a4c5ae504b Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 10 Oct 2023 09:10:57 +0200 Subject: [PATCH] build: Akka 2.9.3-M3 and publish to Akka repo (#1062) * alpakka 7.0.0-M2 --- .github/workflows/publish.yml | 6 +-- build.sbt | 10 ++++- docs/release-train-issue-template.md | 6 +-- project/Common.scala | 2 - project/Dependencies.scala | 8 ++-- project/Publish.scala | 63 ++++++++++++++++++++++++++++ 6 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 project/Publish.scala diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 004b02d6..39e3ab56 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,9 +42,9 @@ jobs: env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - run: sbt ci-release + PUBLISH_USER: ${{ secrets.PUBLISH_USER }} + PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} + run: sbt +publishSigned documentation: # runs on main repo only diff --git a/build.sbt b/build.sbt index 073b613a..9435098b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,7 @@ import com.typesafe.sbt.packager.docker._ +import com.geirsson.CiReleasePlugin +ThisBuild / resolvers += "Akka library repository".at("https://repo.akka.io/maven") ThisBuild / resolvers ++= { if (System.getProperty("override.akka.version") != null) Seq("Akka Snapshots".at("https://oss.sonatype.org/content/repositories/snapshots/")) @@ -8,11 +10,13 @@ ThisBuild / resolvers ++= { // make version compatible with docker for publishing example project ThisBuild / dynverSeparator := "-" +// append -SNAPSHOT to version when isSnapshot +ThisBuild / dynverSonatypeSnapshots := true lazy val root = project .in(file(".")) .enablePlugins(Common, ScalaUnidocPlugin) - .disablePlugins(SitePlugin) + .disablePlugins(SitePlugin, CiReleasePlugin) .aggregate(core) .settings(name := "akka-persistence-cassandra-root", publish / skip := true) @@ -22,6 +26,7 @@ dumpSchema := (core / Test / runMain).toTask(" akka.persistence.cassandra.PrintC lazy val core = project .in(file("core")) .enablePlugins(Common, AutomateHeaderPlugin) + .disablePlugins(CiReleasePlugin) .settings( name := "akka-persistence-cassandra", libraryDependencies ++= Dependencies.akkaPersistenceCassandraDependencies, @@ -50,14 +55,17 @@ lazy val endToEndExample = project // Docker image is only for running in k8s Universal / javaOptions ++= Seq("-J-Dconfig.resource=kubernetes.conf")) .enablePlugins(DockerPlugin, JavaAppPackaging) + .disablePlugins(CiReleasePlugin) lazy val dseTest = project .in(file("dse-test")) .dependsOn(core % "test->test") .settings(libraryDependencies ++= Dependencies.dseTestDependencies) + .disablePlugins(CiReleasePlugin) lazy val docs = project .enablePlugins(Common, AkkaParadoxPlugin, ParadoxSitePlugin, PreprocessPlugin, PublishRsyncPlugin) + .disablePlugins(CiReleasePlugin) .dependsOn(core) .settings( name := "Akka Persistence Cassandra", diff --git a/docs/release-train-issue-template.md b/docs/release-train-issue-template.md index 9971c380..ac35da5d 100644 --- a/docs/release-train-issue-template.md +++ b/docs/release-train-issue-template.md @@ -20,15 +20,15 @@ Variables to be expanded in this template: - [ ] Make sure all important PRs have been merged - [ ] Wait until [main build finished](https://github.com/akka/akka-persistence-cassandra/actions) after merging the latest PR - [ ] Update the [draft release](https://github.com/akka/akka-persistence-cassandra/releases) with the next tag version `v$VERSION$`, title and release description. Use the `Publish release` button, which will create the tag. -- [ ] Check that GitHub Actions release build has executed successfully (GitHub Actions will start a [CI build](https://github.com/akka/akka-persistence-cassandra/actions) for the new tag and publish artifacts to Maven central via Sonatype) +- [ ] Check that GitHub Actions release build has executed successfully (GitHub Actions will start a [CI build](https://github.com/akka/akka-persistence-cassandra/actions) for the new tag and publish artifacts to https://repo.akka.io/maven) ### Check availability - [ ] Check [API](https://doc.akka.io/api/akka-persistence-cassandra/$VERSION$/) documentation - [ ] Check [reference](https://doc.akka.io/docs/akka-persistence-cassandra/$VERSION$/) documentation. Check that the reference docs were deployed and show a version warning (see section below on how to fix the version warning). -- [ ] Check the release on [Maven central](https://repo1.maven.org/maven2/com/typesafe/akka/akka-persistence-cassandra_2.13/$VERSION$/) +- [ ] Check the release on https://repo.akka.io/maven/com/typesafe/akka/akka-persistence-cassandra_2.13/$VERSION$/akka-persistence-cassandra_2.13-$VERSION$.pom -### When everything is on maven central +### When everything is on https://repo.akka.io/maven - [ ] Log into `gustav.akka.io` as `akkarepo` - [ ] If this updates the `current` version, run `./update-akka-persistence-cassandra-current-version.sh $VERSION$` - [ ] otherwise check changes and commit the new version to the local git repository diff --git a/project/Common.scala b/project/Common.scala index ffdc1327..e4fc0d8c 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -5,7 +5,6 @@ import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ import sbt.Keys._ import sbt._ import sbt.plugins.JvmPlugin -import xerial.sbt.Sonatype.autoImport.sonatypeProfileName object Common extends AutoPlugin { @@ -88,7 +87,6 @@ object Common extends AutoPlugin { apiURL := Some(url(s"https://doc.akka.io/api/akka-persistence-cassandra/${projectInfoVersion.value}")), headerLicense := Some( HeaderLicense.Custom("""Copyright (C) 2016-2023 Lightbend Inc. """)), - sonatypeProfileName := "com.typesafe", Test / logBuffered := System.getProperty("akka.logBufferedTests", "false").toBoolean, // show full stack traces and test case durations Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"), diff --git a/project/Dependencies.scala b/project/Dependencies.scala index fe9e8253..a4204dfc 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -7,17 +7,17 @@ object Dependencies { val Scala2Versions = Seq(Scala213) val ScalaVersions = Dependencies.Scala2Versions :+ Dependencies.Scala3 - val AkkaVersion = System.getProperty("override.akka.version", "2.7.0") + val AkkaVersion = System.getProperty("override.akka.version", "2.9.0-M3") val AkkaVersionInDocs = AkkaVersion.take(3) val CassandraVersionInDocs = "4.0" // Should be sync with the version of the driver in Alpakka Cassandra val CassandraDriverVersion = "4.17.0" val DriverVersionInDocs = "4.14" - val AlpakkaVersion = "6.0.0" - val AlpakkaVersionInDocs = AlpakkaVersion + val AlpakkaVersion = "7.0.0-M2" + val AlpakkaVersionInDocs = "7.0" // for example - val AkkaManagementVersion = "1.2.0" + val AkkaManagementVersion = "1.5.0-M1" val Logback = "ch.qos.logback" % "logback-classic" % "1.2.12" diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 00000000..1813de35 --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023 Lightbend Inc. + */ + +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 && Common + 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.typesafe", + 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 + } + } +}