diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4ee469d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,13 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + uses: guardian/gha-scala-library-release-workflow/.github/workflows/reusable-release.yml@main + permissions: { contents: write, pull-requests: write } + secrets: + SONATYPE_PASSWORD: ${{ secrets.AUTOMATED_MAVEN_RELEASE_SONATYPE_PASSWORD }} + PGP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_PGP_SECRET }} + GITHUB_APP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY }} diff --git a/README.md b/README.md index 95735b7..69b946a 100644 --- a/README.md +++ b/README.md @@ -74,22 +74,11 @@ Follow the instructions in the [node client README](./anghammarad-client-node/RE ## Releasing the Scala client -You will need: +This repo uses [`gha-scala-library-release-workflow`](https://github.com/guardian/gha-scala-library-release-workflow) +to automate publishing the Scala client (both full & preview releases) - see +[**Making a Release**](https://github.com/guardian/gha-scala-library-release-workflow/blob/main/docs/making-a-release.md). -* Sonatype account that is a member of the Guardian's group -* A published PGP key -* Global SBT configuration to include your sonatype ceredentials - -With the above in place, you can release a new version using sbt's -`release` command from the root project. - -```bash -sbt release -``` - -The sbt-release plugin will suggest the next version number, but consider -what the next version number should be by considering the change against -[the semantic versioning guidelines](https://semver.org/). +You can run this workflow from Github Actions. It will automatically determine the next version number based on the changes that have been made. ## Releasing the Node client diff --git a/build.sbt b/build.sbt index b6d2883..4b57f8c 100644 --- a/build.sbt +++ b/build.sbt @@ -1,3 +1,6 @@ +import sbtrelease.ReleaseStateTransformations.* +import sbtversionpolicy.withsbtrelease.ReleaseVersion + val compilerOptions = Seq( "-deprecation", "-Xfatal-warnings", @@ -19,21 +22,12 @@ inThisBuild(Seq( scalacOptions ++= Seq( "-deprecation", "-Xfatal-warnings", - "-encoding", "UTF-8" + "-encoding", "UTF-8", + "-release:11", ), // sonatype metadata organization := "com.gu", - licenses := Seq("Apache V2" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), - scmInfo := Some( - ScmInfo( - url("https://github.com/guardian/anghammarad"), - "scm:git@github.com:guardian/anghammarad" - ) - ), - homepage := scmInfo.value.map(_.browseUrl), - developers := List( - Developer(id = "guardian", name = "Guardian", email = null, url = url("https://github.com/guardian")) - ) + licenses := Seq(License.Apache2), )) val awsSdkVersion = "1.12.697" @@ -48,20 +42,27 @@ lazy val root = project .in(file(".")) .settings( name := "anghammarad-root", - // publish settings - releaseCrossBuild := true, publish / skip := true, - publishTo := sonatypePublishTo.value, - releaseProcess += releaseStepCommandAndRemaining("sonatypeRelease"), + // publish settings, for common and client + releaseCrossBuild := true, + releaseProcess := Seq[ReleaseStep]( + checkSnapshotDependencies, + inquireVersions, + runClean, + runTest, + setReleaseVersion, + commitReleaseVersion, + tagRelease, + setNextVersion, + commitNextVersion, + ), + releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease().value, ) .aggregate(anghammarad, client, common, dev) lazy val common = project .settings( name := "anghammarad-common", - // publish settings - releasePublishArtifactsAction := PgpKeys.publishSigned.value, - publishTo := sonatypePublishTo.value, ) lazy val client = project @@ -74,9 +75,6 @@ lazy val client = project "com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion, "org.scalatest" %% "scalatest" % scalaTestVersion % Test ), - // publish settings - releasePublishArtifactsAction := PgpKeys.publishSigned.value, - publishTo := sonatypePublishTo.value, assemblySettings, ) @@ -104,9 +102,9 @@ lazy val anghammarad = project "ch.qos.logback" % "logback-classic" % "1.5.4", "org.scalatest" %% "scalatest" % scalaTestVersion % Test ), - publish / skip := true, assembly / assemblyOutputPath := file("anghammarad/anghammarad.jar"), assemblySettings, + publish / skip := true, ) lazy val dev = project @@ -115,7 +113,7 @@ lazy val dev = project libraryDependencies ++= Seq( "com.github.scopt" %% "scopt" % "4.1.0" ), - publish / skip := true, assemblySettings, + publish / skip := true, ) .dependsOn(common, anghammarad, client) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4b86066..716427a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,12 +2,9 @@ addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0") -addSbtPlugin("com.gu" % "sbt-riffraff-artifact" % "1.1.18") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0") +// for publishing the scala client addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0") - -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") - addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0") - -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.0")