From f7a1e154f34aa285206ff0f73b4709fefe124d14 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Mon, 9 Oct 2023 11:11:04 +0200 Subject: [PATCH] build: Akka 2.9.3-M3 and publish to Akka repo (#773) --- .github/workflows/release.yml | 6 +-- build.sbt | 12 +++--- docs/release-train-issue-template.md | 6 +-- project/Dependencies.scala | 2 +- project/ProjectAutoPlugin.scala | 9 ++-- project/Publish.scala | 62 ++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 project/Publish.scala diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 21878bf70..37e9953c2 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 57292a6bf..77bdeb2ac 100644 --- a/build.sbt +++ b/build.sbt @@ -1,19 +1,19 @@ import com.lightbend.paradox.apidoc.ApidocPlugin.autoImport.apidocRootPackage +import com.geirsson.CiReleasePlugin -// FIXME remove switching to final Akka version -ThisBuild / resolvers += "Akka Snapshots".at("https://oss.sonatype.org/content/repositories/snapshots/") +ThisBuild / resolvers += "Akka library repository".at("https://repo.akka.io/maven") lazy val `akka-persistence-jdbc` = project .in(file(".")) .enablePlugins(ScalaUnidocPlugin) - .disablePlugins(MimaPlugin, SitePlugin) + .disablePlugins(MimaPlugin, SitePlugin, CiReleasePlugin) .aggregate(core, docs, migrator) .settings(publish / skip := true) lazy val core = project .in(file("core")) .enablePlugins(MimaPlugin) - .disablePlugins(SitePlugin) + .disablePlugins(SitePlugin, CiReleasePlugin) .configs(IntegrationTest.extend(Test)) .settings(Defaults.itSettings) .settings( @@ -26,7 +26,7 @@ lazy val core = project lazy val migrator = project .in(file("migrator")) - .disablePlugins(SitePlugin, MimaPlugin) + .disablePlugins(SitePlugin, MimaPlugin, CiReleasePlugin) .configs(IntegrationTest.extend(Test)) .settings(Defaults.itSettings) .settings( @@ -38,7 +38,7 @@ lazy val migrator = project lazy val docs = project .enablePlugins(ProjectAutoPlugin, AkkaParadoxPlugin, ParadoxSitePlugin, PreprocessPlugin, PublishRsyncPlugin) - .disablePlugins(MimaPlugin) + .disablePlugins(MimaPlugin, CiReleasePlugin) .settings( name := "Akka Persistence JDBC", publish / skip := true, diff --git a/docs/release-train-issue-template.md b/docs/release-train-issue-template.md index 061b1cf70..558d21a72 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/akka-persistence-jdbc/actions) after merging the latest PR - [ ] Update the [draft release](https://github.com/akka/akka-persistence-jdbc/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-jdbc/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-jdbc/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-jdbc/$VERSION$/) documentation - [ ] Check [reference](https://doc.akka.io/docs/akka-persistence-jdbc/$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-persistence-jdbc_2.13/$VERSION$/) +- [ ] Check the release on https://repo.akka.io/maven/com/lightbend/akka/akka-persistence-jdbc_2.13/$VERSION$/akka-persistence-jdbc_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-jdbc-current-version.sh $VERSION$` - [ ] otherwise check changes and commit the new version to the local git repository diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9c0f99aeb..c3736e60e 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -6,7 +6,7 @@ object Dependencies { val ScalaVersions = Seq(Scala213) - val AkkaVersion = "2.7.0" + val AkkaVersion = "2.9.0-M3" val AkkaBinaryVersion = AkkaVersion.take(3) val SlickVersion = "3.4.1" diff --git a/project/ProjectAutoPlugin.scala b/project/ProjectAutoPlugin.scala index cffe19d05..9c7735a46 100644 --- a/project/ProjectAutoPlugin.scala +++ b/project/ProjectAutoPlugin.scala @@ -4,12 +4,12 @@ import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport.{ headerLicense, Head import sbt.Keys._ import sbt._ import sbt.plugins.JvmPlugin -import xerial.sbt.Sonatype.autoImport.sonatypeProfileName +import sbtdynver.DynVerPlugin.autoImport.dynverSonatypeSnapshots object ProjectAutoPlugin extends AutoPlugin { object autoImport {} - override val requires = JvmPlugin && HeaderPlugin && CiReleasePlugin + override val requires = JvmPlugin && HeaderPlugin override def globalSettings = Seq( @@ -43,6 +43,8 @@ object ProjectAutoPlugin extends AutoPlugin { crossVersion := CrossVersion.binary, crossScalaVersions := Dependencies.ScalaVersions, scalaVersion := Dependencies.Scala213, + // append -SNAPSHOT to version when isSnapshot + ThisBuild / dynverSonatypeSnapshots := true, Test / fork := false, Test / parallelExecution := false, Test / logBuffered := true, @@ -91,8 +93,7 @@ object ProjectAutoPlugin extends AutoPlugin { headerLicense := Some(HeaderLicense.Custom("""|Copyright (C) 2014 - 2019 Dennis Vriend |Copyright (C) 2019 - 2023 Lightbend Inc. |""".stripMargin)), - resolvers += Resolver.jcenterRepo, - sonatypeProfileName := "com.lightbend") + resolvers += Resolver.jcenterRepo) val disciplineScalacOptions = Set( // "-Xfatal-warnings", diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 000000000..b2bca2586 --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,62 @@ +/* + * 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 && ProjectAutoPlugin + 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 + } + } +}