Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build and include sbt publish GHA workflow #193

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/release-scala-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release Scala client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just by convention, this file is called release.yml in all the other repos that have gha-scala-library-release-workflow - would it be ok to rename this file to match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble is that this repo has a node client and a Scala client. I didn't want the workflow to give the impression it would do both. Let me know if you feel super strongly, but I don't think hogging the word "release" in the workflow namespace is always a good idea!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense - what we've actually done with other libraries that publish both NPM & Scala packages is that we've tied them together in a single release workflow (at which point, it's kind of ok to just call it release.yml again). We allow the NPM release to utilise the Scala libraries version number, so that their releases are synchronised and it's easy to see whether the NPM and Scala libraries are from the same point in time.

We've done this for:

image

These libraries where largely completely defined by their thrift definitions, so if one library wanted to change, the other did too. This might not be the case with anghammarad, so it might not apply here, but it is quite nice to just have one button to press.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok makes sense! I'll rename it and we can consider unifying these libraries in the future.


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 }}
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:[email protected]: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")
Loading