Skip to content

Commit

Permalink
Merge pull request #135 from guardian/an/automated-release
Browse files Browse the repository at this point in the history
Automated releases using gha-scala-library-release-workflow
  • Loading branch information
andrew-nowak authored Apr 17, 2024
2 parents c8b3c93 + 2ed068a commit b30caa1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 98 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, 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 }}
134 changes: 42 additions & 92 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,13 @@ import sbtrelease._
import ReleaseStateTransformations._
import xerial.sbt.Sonatype._
import play.sbt.PlayImport.PlayKeys._
import sbtversionpolicy.withsbtrelease.ReleaseVersion

val scala212 = "2.12.15"
val scala213 = "2.13.8"
val scala212 = "2.12.17"
val scala213 = "2.13.9"

ThisBuild / scalaVersion := scala213

// See below - the release process itself is correctly configured to publish the cross-built
// subprojects, invoking sbt with + or sbt-release with "release cross" only serves to confuse things.
// Always run release as `sbt clean release`!
val checkRunCorrectly = ReleaseStep(action = st => {
val allcommands = (st.history.executed ++ st.currentCommand ++ st.remainingCommands).map(_.commandLine)
val crossCommands = allcommands.exists(_ contains "+")
val releaseCommandWithArgs = allcommands.exists(cmd => cmd.contains("release") && cmd != "release")

if (crossCommands) {
st.log.error("Don't run release commands with cross building! Try again with 'sbt clean release'.")
sys.exit(1)
} else if (releaseCommandWithArgs) {
st.log.error("Don't run the release command with arguments! Try again with 'sbt clean release'.")
sys.exit(1)
}

st
})

val commonSettings =
Seq(
crossScalaVersions := List(scala212, scala213),
Expand All @@ -39,145 +21,114 @@ val commonSettings =
"-feature",
"-deprecation",
// upgrade warnings to errors except deprecations
"-Wconf:cat=deprecation:ws,any:e"
"-Wconf:cat=deprecation:ws,any:e",
"-release:8"
),
publishArtifact := false
licenses := Seq(License.Apache2),
)

val sonatypeReleaseSettings = {
sonatypeSettings ++ Seq(
publishTo := sonatypePublishToBundle.value,
licenses := Seq("Apache V2" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")),
scmInfo := Some(ScmInfo(
url("https://github.com/guardian/pan-domain-authentication"),
"scm:git:git@github.com:guardian/pan-domain-authentication.git"
)),
homepage := Some(url("https://github.com/guardian/pan-domain-authentication")),
developers := List(Developer(
id = "GuardianEdTools",
name = "Guardian Editorial Tools",
email = "digitalcms.dev@theguardian.com",
url = url("https://github.com/orgs/guardian/teams/digital-cms")
)),
// sbt and sbt-release implement cross-building support differently. sbt does it better
// (it supports each subproject having different crossScalaVersions), so disable sbt-release's
// implementation, and do the publish step with a `+`,
// ie. (`releaseStepCommandAndRemaining("+publishSigned")`)
// See https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Note+about+sbt-release
// Never run with "release cross" or "+release"! Odd things start happening
releaseCrossBuild := false,
releaseProcess := Seq[ReleaseStep](
checkRunCorrectly,
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
)
}

lazy val panDomainAuthVerification = project("pan-domain-auth-verification")
.settings(sonatypeReleaseSettings: _*)
lazy val panDomainAuthVerification = subproject("pan-domain-auth-verification")
.settings(
libraryDependencies
++= cryptoDependencies
++ awsDependencies
++ testDependencies
++ loggingDependencies
++ scalaCollectionCompatDependencies,
publishArtifact := true
)


lazy val panDomainAuthCore = project("pan-domain-auth-core")
lazy val panDomainAuthCore = subproject("pan-domain-auth-core")
.dependsOn(panDomainAuthVerification)
.settings(sonatypeReleaseSettings: _*)
.settings(
libraryDependencies
++= awsDependencies
++ googleDirectoryApiDependencies
++ cryptoDependencies
++ testDependencies
++ scalaCollectionCompatDependencies,
publishArtifact := true
)

lazy val panDomainAuthPlay_2_8 = project("pan-domain-auth-play_2-8")
lazy val panDomainAuthPlay_2_8 = subproject("pan-domain-auth-play_2-8")
.settings(sourceDirectory := (ThisBuild / baseDirectory).value / "pan-domain-auth-play" / "src")
.settings(sonatypeReleaseSettings: _*)
.settings(
libraryDependencies
++= playLibs_2_8
++ scalaCollectionCompatDependencies,
publishArtifact := true
).dependsOn(panDomainAuthCore)

lazy val panDomainAuthPlay_2_9 = project("pan-domain-auth-play_2-9")
lazy val panDomainAuthPlay_2_9 = subproject("pan-domain-auth-play_2-9")
.settings(sourceDirectory := (ThisBuild / baseDirectory).value / "pan-domain-auth-play" / "src")
.settings(sonatypeReleaseSettings: _*)
.settings(
crossScalaVersions := Seq(scala213),
libraryDependencies
++= playLibs_2_9
++ scalaCollectionCompatDependencies,
publishArtifact := true
).dependsOn(panDomainAuthCore)

lazy val panDomainAuthPlay_3_0 = project("pan-domain-auth-play_3-0")
lazy val panDomainAuthPlay_3_0 = subproject("pan-domain-auth-play_3-0")
.settings(sourceDirectory := (ThisBuild / baseDirectory).value / "pan-domain-auth-play" / "src")
.settings(sonatypeReleaseSettings: _*)
.settings(
crossScalaVersions := Seq(scala213),
libraryDependencies
++= playLibs_3_0
++ scalaCollectionCompatDependencies,
publishArtifact := true
).dependsOn(panDomainAuthCore)

lazy val panDomainAuthHmac_2_8 = project("panda-hmac-play_2-8")
lazy val panDomainAuthHmac_2_8 = subproject("panda-hmac-play_2-8")
.settings(sourceDirectory := (ThisBuild / baseDirectory).value / "pan-domain-auth-hmac" / "src")
.settings(sonatypeReleaseSettings: _*)
.settings(
libraryDependencies ++= hmacLibs ++ playLibs_2_8 ++ testDependencies,
publishArtifact := true
).dependsOn(panDomainAuthPlay_2_8)
lazy val panDomainAuthHmac_2_9 = project("panda-hmac-play_2-9")

lazy val panDomainAuthHmac_2_9 = subproject("panda-hmac-play_2-9")
.settings(sourceDirectory := (ThisBuild / baseDirectory).value / "pan-domain-auth-hmac" / "src")
.settings(sonatypeReleaseSettings: _*)
.settings(
crossScalaVersions := Seq(scala213),
libraryDependencies ++= hmacLibs ++ playLibs_2_9 ++ testDependencies,
publishArtifact := true
).dependsOn(panDomainAuthPlay_2_9)
lazy val panDomainAuthHmac_3_0 = project("panda-hmac-play_3-0")

lazy val panDomainAuthHmac_3_0 = subproject("panda-hmac-play_3-0")
.settings(sourceDirectory := (ThisBuild / baseDirectory).value / "pan-domain-auth-hmac" / "src")
.settings(sonatypeReleaseSettings: _*)
.settings(
crossScalaVersions := Seq(scala213),
libraryDependencies ++= hmacLibs ++ playLibs_3_0 ++ testDependencies,
publishArtifact := true
).dependsOn(panDomainAuthPlay_3_0)

lazy val exampleApp = project("pan-domain-auth-example")
lazy val exampleApp = subproject("pan-domain-auth-example")
.enablePlugins(PlayScala)
.settings(libraryDependencies ++= (awsDependencies :+ ws))
.dependsOn(panDomainAuthPlay_2_9)
.settings(
crossScalaVersions := Seq(scala213),
publishArtifact := false,
publish / skip := true,
playDefaultPort := 9500
)

lazy val sonatypeReleaseSettings = {
sonatypeSettings ++ Seq(
// sbt and sbt-release implement cross-building support differently. sbt does it better
// (it supports each subproject having different crossScalaVersions), so disable sbt-release's
// implementation, and do the publish step with a `+`,
// ie. (`releaseStepCommandAndRemaining("+publishSigned")`)
// See https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Note+about+sbt-release
// Never run with "release cross" or "+release"! Odd things start happening
releaseCrossBuild := false,
releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease().value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
setNextVersion,
commitNextVersion
)
)
}

lazy val root = Project("pan-domain-auth-root", file(".")).aggregate(
panDomainAuthVerification,
panDomainAuthCore,
Expand All @@ -191,9 +142,8 @@ lazy val root = Project("pan-domain-auth-root", file(".")).aggregate(
).settings(sonatypeReleaseSettings)
.settings(
organization := "com.gu",
publishArtifact := false,
publish / skip := true,
)

def project(path: String): Project =
def subproject(path: String): Project =
Project(path, file(path)).settings(commonSettings: _*)
8 changes: 3 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.0")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.4")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.0")
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "3.0.3-SNAPSHOT"
ThisBuild / version := "3.0.3-SNAPSHOT"

0 comments on commit b30caa1

Please sign in to comment.