From 29ecc1305b6c33f430c1ccc838af35e0dd394a10 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Mon, 9 Oct 2023 16:26:04 +0200 Subject: [PATCH] build: Akka 2.9.3-M3 and publish to Akka repo (#3021) * remove deprecated in ElasticsearchConnectionSettings * Akka HTTP 10.6.0-M2 --- .github/workflows/publish.yml | 6 +- build.sbt | 16 +++-- docs/release-train-issue-template.md | 6 +- ...earchConnectionSettings.backwards.excludes | 3 + .../ElasticsearchConnectionSettings.scala | 26 -------- project/Common.scala | 7 +- project/Dependencies.scala | 13 ++-- project/Publish.scala | 64 +++++++++++++++++++ project/plugins.sbt | 4 +- 9 files changed, 96 insertions(+), 49 deletions(-) create mode 100644 elasticsearch/src/main/mima-filters/6.0.2.backwards.excludes/ElasticsearchConnectionSettings.backwards.excludes create mode 100644 project/Publish.scala diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a9c009eff8..98b0f50c98 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,9 +38,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 eeea3c7358..9048e25829 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,9 @@ +import com.geirsson.CiReleasePlugin + lazy val alpakka = project .in(file(".")) .enablePlugins(ScalaUnidocPlugin) - .disablePlugins(MimaPlugin, SitePlugin) + .disablePlugins(MimaPlugin, SitePlugin, CiReleasePlugin) .aggregate( amqp, avroparquet, @@ -469,7 +471,7 @@ def alpakkaProject(projectId: String, moduleName: String, additionalSettings: sb import com.typesafe.tools.mima.core._ Project(id = projectId, base = file(projectId)) .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(SitePlugin) + .disablePlugins(SitePlugin, CiReleasePlugin) .settings( name := s"akka-stream-alpakka-$projectId", licenses := { @@ -498,10 +500,12 @@ def alpakkaProject(projectId: String, moduleName: String, additionalSettings: sb def internalProject(projectId: String, additionalSettings: sbt.Def.SettingsDefinition*): Project = Project(id = projectId, base = file(projectId)) .enablePlugins(AutomateHeaderPlugin) - .disablePlugins(SitePlugin, MimaPlugin) - .settings(name := s"akka-stream-alpakka-$projectId", - publish / skip := true, - scalacOptions += "-Wconf:cat=deprecation&msg=.*JavaConverters.*:s") + .disablePlugins(SitePlugin, MimaPlugin, CiReleasePlugin) + .settings( + name := s"akka-stream-alpakka-$projectId", + publish / skip := true, + scalacOptions += "-Wconf:cat=deprecation&msg=.*JavaConverters.*:s" + ) .settings(additionalSettings: _*) Global / onLoad := (Global / onLoad).value.andThen { s => diff --git a/docs/release-train-issue-template.md b/docs/release-train-issue-template.md index 7c4e3586ef..73bfde4d7d 100644 --- a/docs/release-train-issue-template.md +++ b/docs/release-train-issue-template.md @@ -25,15 +25,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/actions) after merging the latest PR - [ ] Update the [draft release](https://github.com/akka/alpakka/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/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/actions) for the new tag and publish artifacts to https://repo.akka.io/maven) ### Check availability - [ ] Check [API](https://doc.akka.io/api/alpakka/$VERSION$/) documentation - [ ] Check [reference](https://doc.akka.io/docs/alpakka/$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/lightbend/akka/akka-stream-alpakka-xml_2.13/$VERSION$/) +- [ ] Check the release on https://repo.akka.io/maven/com/lightbend/akka/akka-stream-alpakka-xml_2.13/$VERSION$/akka-stream-alpakka-xml_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-current-version.sh $VERSION$` - [ ] otherwise check changes and commit the new version to the local git repository diff --git a/elasticsearch/src/main/mima-filters/6.0.2.backwards.excludes/ElasticsearchConnectionSettings.backwards.excludes b/elasticsearch/src/main/mima-filters/6.0.2.backwards.excludes/ElasticsearchConnectionSettings.backwards.excludes new file mode 100644 index 0000000000..b44bebdae6 --- /dev/null +++ b/elasticsearch/src/main/mima-filters/6.0.2.backwards.excludes/ElasticsearchConnectionSettings.backwards.excludes @@ -0,0 +1,3 @@ +# Remove deprecated +ProblemFilters.exclude[DirectMissingMethodProblem]("akka.stream.alpakka.elasticsearch.ElasticsearchConnectionSettings.withConnectionContext") +ProblemFilters.exclude[DirectMissingMethodProblem]("akka.stream.alpakka.elasticsearch.ElasticsearchConnectionSettings.withConnectionContext") diff --git a/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/ElasticsearchConnectionSettings.scala b/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/ElasticsearchConnectionSettings.scala index 4f18a05b17..d45de15fb5 100644 --- a/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/ElasticsearchConnectionSettings.scala +++ b/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/ElasticsearchConnectionSettings.scala @@ -7,11 +7,9 @@ package akka.stream.alpakka.elasticsearch import akka.http.scaladsl.{ConnectionContext, HttpsConnectionContext} import akka.http.scaladsl.model.HttpHeader import akka.http.scaladsl.model.HttpHeader.ParsingResult -import akka.japi.Util import scala.collection.JavaConverters._ import javax.net.ssl.SSLContext -import scala.compat.java8.OptionConverters final class ElasticsearchConnectionSettings private ( val baseUrl: String, @@ -47,30 +45,6 @@ final class ElasticsearchConnectionSettings private ( copy(headers = scalaHeaders) } - /** Scala API */ - @deprecated("prefer ElasticsearchConnectionSettings.withSSLContext", "3.1.0") - @Deprecated - def withConnectionContext(connectionContext: HttpsConnectionContext): ElasticsearchConnectionSettings = - copy(connectionContext = Option(connectionContext)) - - /** Java API */ - @deprecated("prefer ElasticsearchConnectionSettings.withSSLContext", "3.1.0") - @Deprecated - def withConnectionContext( - connectionContext: akka.http.javadsl.HttpsConnectionContext - ): ElasticsearchConnectionSettings = { - val scalaContext = new HttpsConnectionContext( - connectionContext.getSslContext, - None, - OptionConverters.toScala(connectionContext.getEnabledCipherSuites).map(Util.immutableSeq(_)), - OptionConverters.toScala(connectionContext.getEnabledProtocols).map(Util.immutableSeq(_)), - OptionConverters.toScala(connectionContext.getClientAuth), - OptionConverters.toScala(connectionContext.getSslParameters) - ) - - copy(connectionContext = Option(scalaContext)) - } - def withSSLContext( sslContext: SSLContext ): ElasticsearchConnectionSettings = { diff --git a/project/Common.scala b/project/Common.scala index 4676330df9..5503a533e5 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -7,7 +7,7 @@ import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._ import com.lightbend.paradox.projectinfo.ParadoxProjectInfoPluginKeys._ import com.lightbend.sbt.JavaFormatterPlugin.autoImport.javafmtOnCompile import com.typesafe.tools.mima.plugin.MimaKeys._ -import xerial.sbt.Sonatype.autoImport.sonatypeProfileName +import sbtdynver.DynVerPlugin.autoImport.dynverSonatypeSnapshots object Common extends AutoPlugin { @@ -123,6 +123,8 @@ object Common extends AutoPlugin { Seq("-Werror") case _ => Seq.empty[String] }), + resolvers += "Akka library repository".at("https://repo.akka.io/maven"), + dynverSonatypeSnapshots := true, autoAPIMappings := true, apiURL := Some(url(s"https://doc.akka.io/api/alpakka/${version.value}/akka/stream/alpakka/index.html")), // show full stack traces and test case durations @@ -139,7 +141,6 @@ object Common extends AutoPlugin { javafmtOnCompile := false, headerLicense := Some( HeaderLicense.Custom("Copyright (C) since 2016 Lightbend Inc. ") - ), - sonatypeProfileName := "com.lightbend" + ) ) } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 4a34db89db..c54b018599 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -10,8 +10,8 @@ object Dependencies { val Scala2Versions = Seq(Scala213) val ScalaVersions = Dependencies.Scala2Versions :+ Dependencies.Scala3 - val AkkaVersion = "2.8.1" - val AkkaBinaryVersion = "2.8" + val AkkaVersion = "2.9.0-M3" + val AkkaBinaryVersion = "2.9" val InfluxDBJavaVersion = "2.15" @@ -19,11 +19,11 @@ object Dependencies { val AwsSpiAkkaHttpVersion = "1.0.1" val ProtobufJavaVersion = "3.21.12" // Sync with plugins.sbt - val AkkaGrpcBinaryVersion = "2.3" + val AkkaGrpcBinaryVersion = "2.4" // sync ignore prefix in scripts/link-validator.conf#L30 - val AkkaHttpVersion = "10.5.1" - val AkkaHttpBinaryVersion = "10.5" - val AlpakkaKafkaVersion = "4.0.2" + val AkkaHttpVersion = "10.6.0-M2" + val AkkaHttpBinaryVersion = "10.6" + val AlpakkaKafkaVersion = "5.0.0-M1" val ScalaTestVersion = "3.2.15" val TestContainersScalaTestVersion = "0.40.3" // pulls Testcontainers 1.16.2 val mockitoVersion = "4.8.1" // check even https://github.com/scalatest/scalatestplus-mockito/releases @@ -234,7 +234,6 @@ object Dependencies { "org.apache.arrow" % "arrow-vector" % "4.0.0" % "provided", "io.grpc" % "grpc-auth" % akka.grpc.gen.BuildInfo.grpcVersion, // ApacheV2 "com.typesafe.akka" %% "akka-http-spray-json" % AkkaHttpVersion, - "com.typesafe.akka" %% "akka-http2-support" % AkkaHttpVersion, "org.apache.arrow" % "arrow-memory-netty" % "4.0.1" % Test, "com.typesafe.akka" %% "akka-discovery" % AkkaVersion ) ++ Mockito diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 0000000000..fc2359176f --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,64 @@ +/* + * 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.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 + } + } +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 20fef36eed..4c779bd595 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,5 @@ +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.4") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") @@ -14,6 +16,6 @@ addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") addSbtPlugin("com.github.sbt" % "sbt-site-paradox" % "1.5.0") // Akka gRPC -- sync with version in Dependencies.scala:22 -addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.3.1") +addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "2.4.0-M1") // templating addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.6.1")