Skip to content

Commit

Permalink
Adopt GHA Scala Library Release Workflow
Browse files Browse the repository at this point in the history
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 scalacenter/sbt-version-policy#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.
  • Loading branch information
rtyley committed Dec 5, 2023
1 parent 22b3192 commit 0345b7f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 5 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ReleaseTransformations._
import ReleaseTransformations.*
import sbtversionpolicy.withsbtrelease.ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease

lazy val baseSettings = Seq(
scalaVersion := "2.13.11",
Expand Down Expand Up @@ -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,
Expand All @@ -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
)
)
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
4 changes: 0 additions & 4 deletions sonatype.sbt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.41-SNAPSHOT"
ThisBuild / version := "1.0.0-SNAPSHOT"

0 comments on commit 0345b7f

Please sign in to comment.