From 0345b7fcd72baccae30cada292e12c25106c8b3c Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Tue, 5 Dec 2023 12:52:54 +0000 Subject: [PATCH] Adopt GHA Scala Library Release Workflow This is the second library, after https://github.com/guardian/etag-caching, to adopt https://github.com/guardian/gha-scala-library-release-workflow/blob/main/README.md . The changes required to adopt the automated workflow: * No need to set `sonatypeProfileName` or `ThisBuild / publishTo`, that's now done by the workflow. * Remove the sign, publish, release & push steps of sbt-release's `releaseProcess` configuration, because the workflow does those now, and the workflow only wants `sbt release` to create the versioning commits, and tag them appropriately. The workflow does the rest itself. * Remove `sbt-pgp` plugin because it's no longer used - the workflow does the signing using `gpg` directly. Additionally, we add **automatic version numbering** based on compatibility assessment performed by `sbt-version-policy`: * Add the `sbt-version-policy` plugin, to allow it to do the compatibility assessment. This also sets the `versionScheme` for this library to `early-semver`, which is the recommended versioning for Scala libraries, and `sbt-version-policy` and correct sbt-eviction-issue-detection pretty much depend on the `versionScheme` being `early-semver`. Thus we also need to switch to using a new semver version number for our library version! * Add the `releaseVersion := fromAggregatedAssessedCompatibilityWithLatestRelease().value` sbt setting, which will intelligently set the release version based on `sbt-version-policy`'s compatibility assessment, thanks to https://github.com/scalacenter/sbt-version-policy/pull/187 . * Use `publish / skip := true`, rather than other hacks like `publish := {}` or `publishArtifact := false`, to tell sbt not to publish modules that we don't want published (typically, the 'root' module) - this is important because `sbt-version-policy` won't understand those hacks, but _will_ understand `publish / skip := true` means that it doesn't need to assess compatibility there. --- .github/workflows/release.yml | 13 +++++++++++++ build.sbt | 14 +++++--------- project/plugins.sbt | 4 ++-- sonatype.sbt | 4 ---- version.sbt | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8654cf6 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 + secrets: + AUTOMATED_MAVEN_RELEASE_PGP_SECRET: ${{ secrets.AUTOMATED_MAVEN_RELEASE_PGP_SECRET }} + AUTOMATED_MAVEN_RELEASE_SONATYPE_PASSWORD: ${{ secrets.AUTOMATED_MAVEN_RELEASE_SONATYPE_PASSWORD }} diff --git a/build.sbt b/build.sbt index 752ba85..60e5fe4 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,5 @@ -import ReleaseTransformations._ +import ReleaseTransformations.* +import sbtversionpolicy.withsbtrelease.ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease lazy val baseSettings = Seq( scalaVersion := "2.13.11", @@ -86,9 +87,8 @@ lazy val `play-secret-rotation-root` = (project in file(".")) `aws-parameterstore-lambda` ) .settings(baseSettings).settings( - publishArtifact := false, - publish := {}, - publishLocal := {}, + publish / skip := true, + releaseVersion := fromAggregatedAssessedCompatibilityWithLatestRelease().value, releaseCrossBuild := true, // true if you cross-build the project for multiple Scala versions releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, @@ -98,11 +98,7 @@ lazy val `play-secret-rotation-root` = (project in file(".")) setReleaseVersion, commitReleaseVersion, tagRelease, - // For non cross-build projects, use releaseStepCommand("publishSigned") - releaseStepCommandAndRemaining("+publishSigned"), - releaseStepCommand("sonatypeBundleRelease"), setNextVersion, - commitNextVersion, - pushChanges + commitNextVersion ) ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 198ab96..43d1883 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ -addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.1.0") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") +addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21") diff --git a/sonatype.sbt b/sonatype.sbt index 77aaa1d..b3900bd 100644 --- a/sonatype.sbt +++ b/sonatype.sbt @@ -1,7 +1,3 @@ -sonatypeProfileName := "com.gu" - -ThisBuild / publishTo := sonatypePublishToBundle.value - ThisBuild / scmInfo := Some(ScmInfo( url("https://github.com/guardian/play-secret-rotation"), "scm:git:git@github.com:guardian/play-secret-rotation.git" diff --git a/version.sbt b/version.sbt index ebd574d..a5f65fc 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.41-SNAPSHOT" +ThisBuild / version := "1.0.0-SNAPSHOT"