From 91cb8571c6c6282b9ad98dc59a08629618a2f7ba Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 6 Oct 2023 12:22:57 +0200 Subject: [PATCH] build: Akka 2.9.3-M3 and publish to Akka repo (#4319) --- .github/workflows/publish.yml | 11 +++--- RELEASING.md | 6 +-- build.sbt | 13 ++++++- docs/release-train-issue-template.md | 8 ++-- .../migration-guide/migration-guide-10.6.x.md | 10 +++++ project/AkkaDependency.scala | 3 +- project/Publish.scala | 38 ++++++++++++++++++- 7 files changed, 70 insertions(+), 19 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 35fdeda5313..d81cff9fd29 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ permissions: jobs: publish-artifacts: - name: Publish artifacts to Sonatype + name: Publish artifacts runs-on: ubuntu-22.04 steps: - name: Checkout @@ -29,15 +29,14 @@ jobs: - name: Install graphviz run: sudo apt-get install -y graphviz - - name: Publish Artifacts to Sonatype / Maven + - name: Publish Artifacts run: | - sbt ci-release + sbt +publishSigned env: - CI_SONATYPE_RELEASE: "; sonatypePrepare; sonatypeBundleUpload; sonatypeClose" PGP_SECRET: ${{ secrets.PGP_SECRET }} PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PUBLISH_USER: ${{ secrets.PUBLISH_USER }} + PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} publish-docs: name: Publish documentation diff --git a/RELEASING.md b/RELEASING.md index a2afe8f475a..aba46afa1f7 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -6,11 +6,7 @@ A few more background information about the process can be found below. ### Release Automation with Github Action -Akka HTTP uses Github Actions and the sbt-ci-release plugin to release artifacts automatically. For commits to the `main` branch, it directly publishes artifacts to the Sonatype snapshot repository. -Tags are published to Maven Central. The process is currently a two-step process: - * Github Actions uses sbt-ci-release to prepare the release and push it to Sonatype, closing the repository at the end. - * At that point a staging repository has been created that can be used to validate artifacts. - * When the release has been validated, the release person needs to manually release the artifacts from staging to Maven Central. +Akka HTTP uses Github Actions and to release artifacts automatically to Akka's library repository. For commits to the `main` branch, it directly publishes artifacts to the Sonatype snapshot repository. ### Releasing only updated docs diff --git a/build.sbt b/build.sbt index 9005ab15ac0..c64353eb5a2 100644 --- a/build.sbt +++ b/build.sbt @@ -83,7 +83,9 @@ lazy val root = Project( base = file(".") ) .enablePlugins(UnidocRoot, NoPublish, PublishRsyncPlugin, AggregatePRValidation, NoScala3) - .disablePlugins(MimaPlugin) + .disablePlugins( + MimaPlugin, + com.geirsson.CiReleasePlugin) // we use publishSigned, but use a pgp utility from CiReleasePlugin .settings( // Unidoc doesn't like macro definitions unidocProjectExcludes := Seq(parsing, compatibilityTests, docs, httpTests, httpJmhBench, httpScalafix, httpScalafixRules, httpScalafixTestInput, httpScalafixTestOutput, httpScalafixTests), @@ -343,6 +345,7 @@ lazy val httpCaching = project("akka-http-caching") def project(name: String) = Project(id = name, base = file(name)) + .disablePlugins(com.geirsson.CiReleasePlugin) // we use publishSigned, but use a pgp utility from CiReleasePlugin def httpMarshallersScalaSubproject(name: String) = Project( @@ -353,6 +356,7 @@ def httpMarshallersScalaSubproject(name: String) = .settings(commonSettings) .enablePlugins(BootstrapGenjavadoc) .enablePlugins(ReproducibleBuildsPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) def httpMarshallersJavaSubproject(name: String) = Project( @@ -363,6 +367,7 @@ def httpMarshallersJavaSubproject(name: String) = .settings(commonSettings) .enablePlugins(BootstrapGenjavadoc) .enablePlugins(ReproducibleBuildsPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) lazy val httpScalafix = project("akka-http-scalafix") .enablePlugins(NoPublish, NoScala3) @@ -376,6 +381,7 @@ lazy val httpScalafixRules = ) .enablePlugins(NoScala3) .disablePlugins(MimaPlugin) // tooling, no bin compat guaranteed + .disablePlugins(com.geirsson.CiReleasePlugin) lazy val httpScalafixTestInput = Project(id = "akka-http-scalafix-test-input", base = file("akka-http-scalafix/scalafix-test-input")) @@ -383,6 +389,7 @@ lazy val httpScalafixTestInput = .addAkkaModuleDependency("akka-stream") .enablePlugins(NoPublish, NoScala3) .disablePlugins(MimaPlugin, HeaderPlugin /* because it gets confused about metaheader required for tests */) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( addCompilerPlugin(scalafixSemanticdb), scalacOptions ++= List( @@ -398,11 +405,13 @@ lazy val httpScalafixTestOutput = .addAkkaModuleDependency("akka-stream") .enablePlugins(NoPublish, NoScala3) .disablePlugins(MimaPlugin, HeaderPlugin /* because it gets confused about metaheader required for tests */) + .disablePlugins(com.geirsson.CiReleasePlugin) lazy val httpScalafixTests = Project(id = "akka-http-scalafix-tests", base = file("akka-http-scalafix/scalafix-tests")) .enablePlugins(NoPublish, NoScala3) .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( publish / skip := true, libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % Dependencies.scalafixVersion % Test cross CrossVersion.full, @@ -499,6 +508,7 @@ lazy val docs = project("docs") lazy val compatibilityTests = Project("akka-http-compatibility-tests", file("akka-http-compatibility-tests")) .enablePlugins(NoPublish) .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .addAkkaModuleDependency("akka-stream", "provided") .settings( libraryDependencies +=( @@ -518,6 +528,7 @@ lazy val compatibilityTests = Project("akka-http-compatibility-tests", file("akk lazy val billOfMaterials = Project("bill-of-materials", file("akka-http-bill-of-materials")) .enablePlugins(BillOfMaterialsPlugin) .disablePlugins(MimaPlugin) + .disablePlugins(com.geirsson.CiReleasePlugin) .settings( name := "akka-http-bom", bomIncludeProjects := userProjects, diff --git a/docs/release-train-issue-template.md b/docs/release-train-issue-template.md index 3b002fb6e21..0c23abbd940 100644 --- a/docs/release-train-issue-template.md +++ b/docs/release-train-issue-template.md @@ -26,17 +26,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/akka-http/actions) after merging the latest PR - [ ] Update the [draft release](https://github.com/akka/akka-http/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-http/actions) for the new tag and publish artifacts to Maven central via Sonatype) -- [ ] Run a test against the staging repository to make sure the release went well, for example by using https://github.com/akka/akka-http-quickstart-scala.g8 and adding the sonatype staging repo with `resolvers += "Staging Repo" at "https://oss.sonatype.org/content/repositories/staging"` -- [ ] Release the staging repository to Maven Central. +- [ ] Check that GitHub Actions release build has executed successfully (GitHub Actions will start a [CI build](https://github.com/akka/akka-http/actions) for the new tag and publish artifacts to https://repo.akka.io/maven) ### Check availability - [ ] Check [API](https://doc.akka.io/api/akka-http/$VERSION$/) documentation - [ ] Check [reference](https://doc.akka.io/docs/akka-http/$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-http-core_2.13/$VERSION$/ +- [ ] Check the release on https://repo.akka.io/maven/com/typesafe/akka/akka-http-core_2.13/$VERSION$/ -### 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-http-current-version.sh $VERSION$` - [ ] otherwise check changes and commit the new version to the local git repository diff --git a/docs/src/main/paradox/migration-guide/migration-guide-10.6.x.md b/docs/src/main/paradox/migration-guide/migration-guide-10.6.x.md index df8e754e1e3..eb7c3239421 100644 --- a/docs/src/main/paradox/migration-guide/migration-guide-10.6.x.md +++ b/docs/src/main/paradox/migration-guide/migration-guide-10.6.x.md @@ -17,6 +17,16 @@ using HTTP/2. The typesafe-ssl-config dependency and deprecated APIs accepting the types from it has been dropped. +## Akka repository + +The Akka dependencies are available from Akka's library repository. To access them there, you need to configure the URL for this repository. + +@@repository [sbt,Maven,Gradle] { +id="akka-repository" +name="Akka library repository" +url="https://repo.akka.io/maven" +} + ## Support for Java 8 removed The published artifacts are targeting Java 11, and later. Supported Java versions are 11 and 17. diff --git a/project/AkkaDependency.scala b/project/AkkaDependency.scala index 8c7e67d2dc3..02cb9cb356b 100644 --- a/project/AkkaDependency.scala +++ b/project/AkkaDependency.scala @@ -44,7 +44,7 @@ object AkkaDependency { } // Default version updated only when needed, https://doc.akka.io//docs/akka/current/project/downstream-upgrade-strategy.html - val minimumExpectedAkkaVersion = "2.9.0-M2" + val minimumExpectedAkkaVersion = "2.9.0-M3" val default = akkaDependency(defaultVersion = minimumExpectedAkkaVersion) val docs = akkaDependency(defaultVersion = minimumExpectedAkkaVersion) @@ -79,6 +79,7 @@ object AkkaDependency { else "com.typesafe.akka" %% module % akkaVersion % config }, + resolvers += "Akka library repository".at("https://repo.akka.io/maven"), resolvers ++= (if (akkaSnapshot) Seq("Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") else Nil) ) } diff --git a/project/Publish.scala b/project/Publish.scala index ad735cbe2ef..58b9e08beb9 100644 --- a/project/Publish.scala +++ b/project/Publish.scala @@ -4,9 +4,14 @@ 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 /** @@ -27,7 +32,38 @@ 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) + None // FIXME snapshot repo + else + Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka/"))), + credentials ++= (if (isSnapshot.value) Seq[Credentials]() else cloudsmithCredentials(validate = false)) ) -} \ No newline at end of file + + 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 + } + } +}