Skip to content

Commit

Permalink
Merge pull request #193 from guardian/migrate-to-sbt-release-workflow
Browse files Browse the repository at this point in the history
Update build and include sbt publish GHA workflow
  • Loading branch information
adamnfish committed Apr 16, 2024
2 parents 3cfd914 + 57e67b4 commit 365f0aa
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 45 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yaml
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 }}
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 22 additions & 24 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import sbtrelease.ReleaseStateTransformations.*
import sbtversionpolicy.withsbtrelease.ReleaseVersion

val compilerOptions = Seq(
"-deprecation",
"-Xfatal-warnings",
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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,
)

Expand Down Expand Up @@ -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
Expand All @@ -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)
9 changes: 3 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 365f0aa

Please sign in to comment.