From da50d91d2a67e9a7722376861b030c9eb1cac812 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 6 Oct 2023 14:12:04 +0200 Subject: [PATCH] build: Akka 2.9.3-M3 and publish to Akka repo (#1209) * build: Akka 2.9.3-M3 and publish to Akka repo * full link, no dir listings --- .github/workflows/release.yml | 6 +- build.sbt | 42 +++++++++--- docs/release-train-issue-template.md | 6 +- integration-test/aws-api-ec2/build.sbt | 2 + integration-test/dns-api-mesos/build.sbt | 3 + integration-test/kubernetes-api-java/pom.xml | 8 +++ integration-test/kubernetes-api/build.sbt | 2 + integration-test/kubernetes-dns/build.sbt | 3 + .../marathon-api-docker/build.sbt | 2 + integration-test/marathon-api/build.sbt | 2 + .../rollingupdate-kubernetes/build.sbt | 2 + project/Common.scala | 6 +- project/Dependencies.scala | 4 +- project/Publish.scala | 67 +++++++++++++++++++ 14 files changed, 134 insertions(+), 21 deletions(-) create mode 100644 project/Publish.scala diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b17f4a6d8..27798fb6c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,9 +43,9 @@ jobs: - name: Publish artifacts for all Scala versions env: 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 af8e16cff..bcd1280a6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,7 @@ import com.typesafe.sbt.packager.docker.{ Cmd, ExecCmd } import sbt.Keys.parallelExecution +ThisBuild / resolvers += "Akka library repository".at("https://repo.akka.io/maven") ThisBuild / resolvers += Resolver.jcenterRepo Global / excludeLintKeys += autoAPIMappings Global / excludeLintKeys += projectInfoVersion @@ -10,7 +11,7 @@ Global / excludeLintKeys += previewPath lazy val `akka-management-root` = project .in(file(".")) .enablePlugins(ScalaUnidocPlugin) - .disablePlugins(MimaPlugin) + .disablePlugins(MimaPlugin, com.geirsson.CiReleasePlugin) .aggregate( // When this aggregate is updated the list of modules in ManifestInfo.checkSameVersion // in AkkaManagement should also be updated @@ -52,6 +53,7 @@ lazy val mimaPreviousArtifactsSet = lazy val `akka-discovery-kubernetes-api` = project .in(file("discovery-kubernetes-api")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-discovery-kubernetes-api", organization := "com.lightbend.akka.discovery", @@ -63,6 +65,7 @@ lazy val `akka-discovery-kubernetes-api` = project lazy val `akka-discovery-marathon-api` = project .in(file("discovery-marathon-api")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-discovery-marathon-api", organization := "com.lightbend.akka.discovery", @@ -73,6 +76,7 @@ lazy val `akka-discovery-marathon-api` = project lazy val `akka-discovery-aws-api` = project .in(file("discovery-aws-api")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-discovery-aws-api", organization := "com.lightbend.akka.discovery", @@ -83,6 +87,7 @@ lazy val `akka-discovery-aws-api` = project lazy val `akka-discovery-aws-api-async` = project .in(file("discovery-aws-api-async")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-discovery-aws-api-async", organization := "com.lightbend.akka.discovery", @@ -93,6 +98,7 @@ lazy val `akka-discovery-aws-api-async` = project lazy val `akka-discovery-consul` = project .in(file("discovery-consul")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-discovery-consul", organization := "com.lightbend.akka.discovery", @@ -104,6 +110,7 @@ lazy val `akka-discovery-consul` = project lazy val `akka-management` = project .in(file("management")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-management", libraryDependencies := Dependencies.ManagementHttp, @@ -113,6 +120,7 @@ lazy val `akka-management` = project lazy val `akka-management-pki` = project .in(file("management-pki")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-management-pki", libraryDependencies := Dependencies.ManagementPki, @@ -122,6 +130,7 @@ lazy val `akka-management-pki` = project lazy val `loglevels-logback` = project .in(file("loglevels-logback")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-management-loglevels-logback", libraryDependencies := Dependencies.LoglevelsLogback, @@ -132,6 +141,7 @@ lazy val `loglevels-logback` = project lazy val `loglevels-log4j2` = project .in(file("loglevels-log4j2")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .disablePlugins(MimaPlugin) .settings( name := "akka-management-loglevels-log4j2", @@ -142,6 +152,7 @@ lazy val `loglevels-log4j2` = project lazy val `cluster-http` = project .in(file("cluster-http")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-management-cluster-http", libraryDependencies := Dependencies.ClusterHttp, @@ -152,6 +163,7 @@ lazy val `cluster-http` = project lazy val `cluster-bootstrap` = project .in(file("cluster-bootstrap")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-management-cluster-bootstrap", libraryDependencies := Dependencies.ClusterBootstrap, @@ -162,6 +174,7 @@ lazy val `cluster-bootstrap` = project lazy val `rolling-update-kubernetes` = project .in(file("rolling-update-kubernetes")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-rolling-update-kubernetes", libraryDependencies := Dependencies.RollingUpdateKubernetes, @@ -176,6 +189,7 @@ lazy val `rolling-update-kubernetes` = project lazy val `lease-kubernetes` = project .in(file("lease-kubernetes")) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-lease-kubernetes", libraryDependencies := Dependencies.LeaseKubernetes, @@ -190,6 +204,7 @@ lazy val `lease-kubernetes` = project lazy val `lease-kubernetes-int-test` = project .in(file("lease-kubernetes-int-test")) .enablePlugins(JavaAppPackaging, DockerPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .dependsOn(`lease-kubernetes`) .enablePlugins(AutomateHeaderPlugin) .disablePlugins(MimaPlugin) @@ -213,8 +228,9 @@ lazy val `lease-kubernetes-int-test` = project lazy val `integration-test-kubernetes-api` = project .in(file("integration-test/kubernetes-api")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, doc / sources := Seq.empty, @@ -224,8 +240,9 @@ lazy val `integration-test-kubernetes-api` = project lazy val `integration-test-kubernetes-api-java` = project .in(file("integration-test/kubernetes-api-java")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, doc / sources := Seq.empty, @@ -240,8 +257,9 @@ lazy val `integration-test-kubernetes-api-java` = project lazy val `integration-test-kubernetes-dns` = project .in(file("integration-test/kubernetes-dns")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, doc / sources := Seq.empty, @@ -256,8 +274,9 @@ lazy val `integration-test-kubernetes-dns` = project lazy val `integration-test-aws-api-ec2-tag-based` = project .in(file("integration-test/aws-api-ec2")) .configs(IntegrationTest) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, doc / sources := Seq.empty, @@ -272,8 +291,9 @@ lazy val `integration-test-aws-api-ec2-tag-based` = project lazy val `integration-test-marathon-api-docker` = project .in(file("integration-test/marathon-api-docker")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "integration-test-marathon-api-docker", publish / skip := true, @@ -288,8 +308,9 @@ lazy val `integration-test-marathon-api-docker` = project lazy val `integration-test-aws-api-ecs` = project .in(file("integration-test/aws-api-ecs")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, doc / sources := Seq.empty @@ -309,8 +330,9 @@ lazy val `integration-test-aws-api-ecs` = project lazy val `integration-test-local` = project .in(file("integration-test/local")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "integration-test-local", publish / skip := true, @@ -326,8 +348,9 @@ lazy val `integration-test-local` = project lazy val `integration-test-rollingupdate-kubernetes` = project .in(file("integration-test/rollingupdate-kubernetes")) - .disablePlugins(MimaPlugin) .enablePlugins(AutomateHeaderPlugin) + .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, doc / sources := Seq.empty, @@ -345,6 +368,7 @@ lazy val docs = project .in(file("docs")) .enablePlugins(AkkaParadoxPlugin, ParadoxSitePlugin, PreprocessPlugin, PublishRsyncPlugin) .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "Akka Management", publish / skip := true, diff --git a/docs/release-train-issue-template.md b/docs/release-train-issue-template.md index b793d3fc3..58c191106 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-management/actions) after merging the latest PR - [ ] Update the [draft release](https://github.com/akka/akka-management/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-management/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-management/actions) for the new tag and publish artifacts to https://repo.akka.io/maven) ### Check availability - [ ] Check [API](https://doc.akka.io/api/akka-management/$VERSION$/) documentation - [ ] Check [reference](https://doc.akka.io/docs/akka-management/$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/management/akka-management_2.13/$VERSION$/) +- [ ] Check the release on https://repo.akka.io/maven/com/lightbend/akka/management/akka-management_2.13/$VERSION$/akka-management-cluster-http_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-management-current-version.sh $VERSION$` - [ ] otherwise check changes and commit the new version to the local git repository diff --git a/integration-test/aws-api-ec2/build.sbt b/integration-test/aws-api-ec2/build.sbt index 57a9f8404..891bcbfa5 100644 --- a/integration-test/aws-api-ec2/build.sbt +++ b/integration-test/aws-api-ec2/build.sbt @@ -1,5 +1,7 @@ enablePlugins(JavaAppPackaging) +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + Universal / packageName := "app" // should produce app.zip libraryDependencies += "com.amazonaws" % "aws-java-sdk-cloudformation" % "1.12.561" % IntegrationTest diff --git a/integration-test/dns-api-mesos/build.sbt b/integration-test/dns-api-mesos/build.sbt index 2e8bfe191..c34f53079 100644 --- a/integration-test/dns-api-mesos/build.sbt +++ b/integration-test/dns-api-mesos/build.sbt @@ -1,4 +1,7 @@ enablePlugins(JavaAppPackaging) + +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + name := "bootstrap-demo-dns-api" scalaVersion := "2.13.12" diff --git a/integration-test/kubernetes-api-java/pom.xml b/integration-test/kubernetes-api-java/pom.xml index 2a9ed4327..d3790456b 100644 --- a/integration-test/kubernetes-api-java/pom.xml +++ b/integration-test/kubernetes-api-java/pom.xml @@ -23,6 +23,14 @@ 2.13 + + + akka-repository + Akka library repository + https://repo.akka.io/maven + + + com.typesafe.akka diff --git a/integration-test/kubernetes-api/build.sbt b/integration-test/kubernetes-api/build.sbt index c9e496be8..e9c39ad53 100644 --- a/integration-test/kubernetes-api/build.sbt +++ b/integration-test/kubernetes-api/build.sbt @@ -2,6 +2,8 @@ import com.typesafe.sbt.packager.docker._ enablePlugins(JavaServerAppPackaging) +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + version := "1.3.3.7" // we hard-code the version here, it could be anything really dockerCommands := diff --git a/integration-test/kubernetes-dns/build.sbt b/integration-test/kubernetes-dns/build.sbt index e54270d45..9070592cf 100644 --- a/integration-test/kubernetes-dns/build.sbt +++ b/integration-test/kubernetes-dns/build.sbt @@ -2,6 +2,8 @@ import com.typesafe.sbt.packager.docker._ enablePlugins(JavaServerAppPackaging) +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + version := "1.3.3.7" // we hard-code the version here, it could be anything really dockerCommands := dockerCommands.value.flatMap { @@ -16,3 +18,4 @@ dockerCommands ++= Seq( Cmd("USER", "root"), Cmd("RUN", "chgrp -R 0 . && chmod -R g=u .") ) + diff --git a/integration-test/marathon-api-docker/build.sbt b/integration-test/marathon-api-docker/build.sbt index fbfa5751f..8dca7a506 100644 --- a/integration-test/marathon-api-docker/build.sbt +++ b/integration-test/marathon-api-docker/build.sbt @@ -6,6 +6,8 @@ scalaVersion := "2.13.12" enablePlugins(JavaServerAppPackaging) +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + version := "1.0" dockerUsername := sys.env.get("DOCKER_USER") diff --git a/integration-test/marathon-api/build.sbt b/integration-test/marathon-api/build.sbt index 80eea3fa7..caef58cdd 100644 --- a/integration-test/marathon-api/build.sbt +++ b/integration-test/marathon-api/build.sbt @@ -2,6 +2,8 @@ enablePlugins(JavaServerAppPackaging) name := "bootstrap-demo-marathon-api" +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + version := "0.1.0" scalaVersion := "2.13.12" diff --git a/integration-test/rollingupdate-kubernetes/build.sbt b/integration-test/rollingupdate-kubernetes/build.sbt index ed36e253e..e199fee20 100644 --- a/integration-test/rollingupdate-kubernetes/build.sbt +++ b/integration-test/rollingupdate-kubernetes/build.sbt @@ -1,6 +1,8 @@ enablePlugins(JavaAppPackaging, DockerPlugin) +resolvers += "Akka library repository".at("https://repo.akka.io/maven") + version := "1.3.3.7" // we hard-code the version here, it could be anything really dockerExposedPorts := Seq(8080, 8558, 2552) diff --git a/project/Common.scala b/project/Common.scala index 9da744324..0adb1c3ff 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -1,4 +1,3 @@ -import com.geirsson.CiReleasePlugin import com.lightbend.paradox.projectinfo.ParadoxProjectInfoPluginKeys._ import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._ @@ -10,7 +9,7 @@ import xerial.sbt.Sonatype.autoImport.sonatypeProfileName object Common extends AutoPlugin { override def trigger = allRequirements - override def requires = plugins.JvmPlugin && HeaderPlugin && CiReleasePlugin + override def requires = plugins.JvmPlugin && HeaderPlugin val currentYear = "2023" @@ -89,8 +88,7 @@ object Common extends AutoPlugin { // -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug". // -a Show stack traces and exception class name for AssertionErrors. testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a"), - scalaVersion := Dependencies.CrossScalaVersions.head, - sonatypeProfileName := "com.lightbend" + scalaVersion := Dependencies.CrossScalaVersions.head ) val isJdk11orHigher: Boolean = { diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 0b128ab11..19910f6a3 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,10 +8,10 @@ object Dependencies { val CrossScalaVersions = Seq(Scala213, Scala3) // Align the versions in integration-test/kubernetes-api-java/pom.xml - val AkkaVersion = "2.9.0-M2" + val AkkaVersion = "2.9.0-M3" val AkkaBinaryVersion = "2.9" // Align the versions in integration-test/kubernetes-api-java/pom.xml - val AkkaHttpVersion = "10.6.0-M1" + val AkkaHttpVersion = "10.6.0-M2" val AkkaHttpBinaryVersion = "10.6" val ScalaTestVersion = "3.2.17" diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 000000000..96c97b57f --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2016-2020 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 && Common + + 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 + } + } +}