From 2eb649a3a94c93d034648993490aff166a342911 Mon Sep 17 00:00:00 2001 From: adamnfish Date: Mon, 15 Apr 2024 17:24:44 +0100 Subject: [PATCH 1/5] Update build and include sbt publish GH workflow Sets up Anghammarad to use the sbt publish GHA workflow, removing redundant publishing plugins for sbt and eliminating sbt config options that are no longer required. We also include the workflow file itself, taken from the docs. https://github.com/guardian/gha-scala-library-release-workflow/blob/main/docs/configuration.md --- .github/workflows/release-scala-client.yaml | 13 ++++++ build.sbt | 44 ++++++++++----------- project/plugins.sbt | 9 ++--- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/release-scala-client.yaml diff --git a/.github/workflows/release-scala-client.yaml b/.github/workflows/release-scala-client.yaml new file mode 100644 index 0000000..9ebb947 --- /dev/null +++ b/.github/workflows/release-scala-client.yaml @@ -0,0 +1,13 @@ +name: Release Scala client + +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/build.sbt b/build.sbt index b6d2883..70b19cc 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")) - ) )) 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") From e97c5362b33c4036d17558afc3f048bd431e1962 Mon Sep 17 00:00:00 2001 From: adamnfish Date: Tue, 16 Apr 2024 12:29:53 +0100 Subject: [PATCH 2/5] Tidy up licence definition --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 70b19cc..4b57f8c 100644 --- a/build.sbt +++ b/build.sbt @@ -27,7 +27,7 @@ inThisBuild(Seq( ), // sonatype metadata organization := "com.gu", - licenses := Seq("Apache V2" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), + licenses := Seq(License.Apache2), )) val awsSdkVersion = "1.12.697" From 37e1b0ce3bfda390c77291dbadf969a38a44b782 Mon Sep 17 00:00:00 2001 From: adamnfish Date: Tue, 16 Apr 2024 12:50:56 +0100 Subject: [PATCH 3/5] Rename release workflow to match other repositories This repository contains an npm client library as well as the scala client. Despite this, we're best off creating a single "release" workflow and if we want to automate the npm flow we can have it be called from this single release workflow. --- .github/workflows/{release-scala-client.yaml => release.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{release-scala-client.yaml => release.yaml} (94%) diff --git a/.github/workflows/release-scala-client.yaml b/.github/workflows/release.yaml similarity index 94% rename from .github/workflows/release-scala-client.yaml rename to .github/workflows/release.yaml index 9ebb947..4ee469d 100644 --- a/.github/workflows/release-scala-client.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Release Scala client +name: Release on: workflow_dispatch: From a567ecf080c7fcd77caa415ed78ad23673182d77 Mon Sep 17 00:00:00 2001 From: adamnfish Date: Tue, 16 Apr 2024 13:00:23 +0100 Subject: [PATCH 4/5] Update README to describe the new sbt release process --- README.md | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 95735b7..b99e208 100644 --- a/README.md +++ b/README.md @@ -74,22 +74,9 @@ Follow the instructions in the [node client README](./anghammarad-client-node/RE ## Releasing the Scala client -You will need: +The Scala client is released using [the sbt-release workflow](https://github.com/guardian/gha-scala-library-release-workflow) on Github. -* 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 From 57e67b481aa97026996c0f197d97efb0f3d5fd38 Mon Sep 17 00:00:00 2001 From: Adam Fisher Date: Tue, 16 Apr 2024 16:32:08 +0100 Subject: [PATCH 5/5] Update README.md Improve the documentation of the release workflow Co-authored-by: Roberto Tyley --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b99e208..69b946a 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,9 @@ Follow the instructions in the [node client README](./anghammarad-client-node/RE ## Releasing the Scala client -The Scala client is released using [the sbt-release workflow](https://github.com/guardian/gha-scala-library-release-workflow) on Github. +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). You can run this workflow from Github Actions. It will automatically determine the next version number based on the changes that have been made.