From eb45e18cd321397e4133d8ce715b6a719e359b90 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 6 Oct 2023 15:41:30 +0200 Subject: [PATCH 1/2] build: Akka 2.9.3-M3 and publish to Akka repo --- .github/workflows/release.yml | 6 +-- build.sbt | 24 +++++----- docs/release-train-issue-template.md | 6 +-- project/Publish.scala | 68 ++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 project/Publish.scala diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 417e8bc6b..cdc3cd81c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,9 +44,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 84f7c0cb6..06af78584 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,8 @@ import com.typesafe.tools.mima.core.{Problem, ProblemFilters} +import com.geirsson.CiReleasePlugin enablePlugins(AutomateHeaderPlugin) +disablePlugins(CiReleasePlugin) name := "akka-stream-kafka" @@ -15,8 +17,8 @@ val ScalaVersions = Scala2Versions :+ Scala3 val Scala3Settings = Seq(crossScalaVersions := ScalaVersions) -val AkkaBinaryVersionForDocs = "2.7" -val akkaVersion = "2.7.0" +val AkkaBinaryVersionForDocs = "2.9" +val akkaVersion = "2.9.0-M3" // Keep .scala-steward.conf pin in sync val kafkaVersion = "3.5.1" @@ -38,6 +40,7 @@ val confluentLibsExclusionRules = Seq( ) ThisBuild / resolvers ++= Seq( + "Akka library repository".at("https://repo.akka.io/maven"), // for Jupiter interface (JUnit 5) Resolver.jcenterRepo ) @@ -156,15 +159,14 @@ val commonSettings = Def.settings( |""".stripMargin ) ), - projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value), - sonatypeProfileName := "com.typesafe" + projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value) ) lazy val `alpakka-kafka` = project .in(file(".")) .enablePlugins(ScalaUnidocPlugin) - .disablePlugins(SitePlugin, MimaPlugin) + .disablePlugins(SitePlugin, MimaPlugin, CiReleasePlugin) .settings(commonSettings) .settings( publish / skip := true, @@ -213,7 +215,7 @@ lazy val `alpakka-kafka` = lazy val core = project .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(SitePlugin) + .disablePlugins(SitePlugin, CiReleasePlugin) .settings(commonSettings) .settings(VersionGenerator.settings) .settings( @@ -235,7 +237,7 @@ lazy val core = project lazy val testkit = project .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(SitePlugin) + .disablePlugins(SitePlugin, CiReleasePlugin) .settings(commonSettings) .settings( name := "akka-stream-kafka-testkit", @@ -260,7 +262,7 @@ lazy val clusterSharding = project .in(file("./cluster-sharding")) .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(SitePlugin) + .disablePlugins(SitePlugin, CiReleasePlugin) .settings(commonSettings) .settings( name := "akka-stream-kafka-cluster-sharding", @@ -279,7 +281,7 @@ lazy val clusterSharding = project lazy val tests = project .dependsOn(core, testkit, clusterSharding) .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(MimaPlugin, SitePlugin) + .disablePlugins(MimaPlugin, SitePlugin, CiReleasePlugin) .configs(IntegrationTest.extend(Test)) .settings(commonSettings) .settings(Defaults.itSettings) @@ -320,7 +322,7 @@ lazy val tests = project lazy val docs = project .enablePlugins(AkkaParadoxPlugin, ParadoxSitePlugin, SitePreviewPlugin, PreprocessPlugin, PublishRsyncPlugin) - .disablePlugins(MimaPlugin) + .disablePlugins(MimaPlugin, CiReleasePlugin) .settings(commonSettings) .settings( name := "Alpakka Kafka", @@ -374,7 +376,7 @@ lazy val docs = project lazy val benchmarks = project .dependsOn(core, testkit) .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(MimaPlugin, SitePlugin) + .disablePlugins(MimaPlugin, SitePlugin, CiReleasePlugin) .configs(IntegrationTest) .settings(commonSettings) .settings(Defaults.itSettings) diff --git a/docs/release-train-issue-template.md b/docs/release-train-issue-template.md index cb793b27f..4819374e1 100644 --- a/docs/release-train-issue-template.md +++ b/docs/release-train-issue-template.md @@ -24,15 +24,15 @@ Key links: - [ ] Update the revision in Fossa in the Akka Group for the Akka umbrella version, e.g. `22.10`. Note that the revisions for the release is udpated by Akka Group > Projects > Edit. For recent dependency updates the Fossa validation can be triggered from the GitHub actions "Dependency License Scanning". - [ ] Wait until [main build finished](https://github.com/akka/alpakka-kafka/actions) after merging the latest PR - [ ] Update the [draft release](https://github.com/akka/alpakka-kafka/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/alpakka-kafka/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/alpakka-kafka/actions) for the new tag and publish artifacts to https://repo.akka.io/maven) ### Check availability - [ ] Check [API](https://doc.akka.io/api/alpakka-kafka/$VERSION$/) documentation - [ ] Check [reference](https://doc.akka.io/docs/alpakka-kafka/$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-stream-kafka_2.13/$VERSION$/) +- [ ] Check the release on https://repo.akka.io/maven/com/typesafe/akka/akka-stream-kafka_2.13/$VERSION$/akka-stream-kafka_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-alpakka-kafka-current-version.sh $VERSION$` - [ ] otherwise check changes and commit the new version to the local git repository diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 000000000..abc39c3b0 --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2023 Lightbend Inc. + */ +package akka + +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 + 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 + } + } +} From da594f4885a4aac710239c66dbdb5c7bd190e5a0 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Mon, 9 Oct 2023 08:47:10 +0200 Subject: [PATCH 2/2] -SNAPSHOT version --- build.sbt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sbt b/build.sbt index 06af78584..b6c00cb1e 100644 --- a/build.sbt +++ b/build.sbt @@ -95,6 +95,8 @@ val commonSettings = Def.settings( crossScalaVersions := Scala2Versions, scalaVersion := Scala213, crossVersion := CrossVersion.binary, + // append -SNAPSHOT to version when isSnapshot + ThisBuild / dynverSonatypeSnapshots := true, javacOptions ++= Seq( "-Xlint:deprecation", "-Xlint:unchecked",