Skip to content

Commit

Permalink
Set up GHA scala library release workflow
Browse files Browse the repository at this point in the history
- Adopt scala library release GHA workflow

  Following [the example from
  play-secret-rotation](guardian/play-secret-rotation#416),
  rather than set up a new developer credential to release the next
  version of this library, this commit sets up
  [guardian/gha-scala-library-release-workflow](https://github.com/guardian/gha-scala-library-release-workflow).

- Further `gha-scala-library-release-workflow` tweaks

  Further to
  #102 (comment),
  these are a few more tweaks:

  * Delete the entire `sonatype.sbt` file that was providing these keys
    that `gha-scala-library-release-workflow` now takes care of for us:
    * `sonatypeProfileName` - see https://github.com/guardian/gha-scala-library-release-workflow/blob/7d278d4d44e30b4b4c0f6791053bdeb40b8159cb/.github/workflows/reusable-release.yml#L258
    * `publishTo` - see guardian/facia-scala-client#299 (comment)
    * `scmInfo` & `pomExtra` - see guardian/facia-scala-client#299 (review)
    * `homepage` - https://github.com/xerial/sbt-sonatype/blob/da75ed2efe29e7d674a6d6af5103b4aa1cecefb8/src/main/scala/xerial/sbt/Sonatype.scala#L368
  * Specify Java 11-compatible bytecode - see https://github.com/guardian/facia-scala-client/pull/299/files#r1425630691

  As part of some of these changes, I've also removed the vestiges of
  the build-configuration that adapted the build for Scala 2.11 &
  2.12 (eg the `versionDependent()` helper method) - these are no longer
  need since #78 removed support
  for Scala 2.12 in January 2023.

Co-authored-by: Roberto Tyley <[email protected]>
  • Loading branch information
emdash-ie and rtyley committed Dec 18, 2023
1 parent d00f4d6 commit 3a31495
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 58 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 }}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Marley [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.gu/marley_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.gu/marley_2.12)
Marley [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.gu/marley_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.gu/marley_2.12) [![Release](https://github.com/guardian/marley/actions/workflows/release.yml/badge.svg)](https://github.com/guardian/marley/actions/workflows/release.yml)
======

Marley is a library for serialising [Scrooge](https://twitter.github.io/scrooge/) generated classes representing
Expand Down Expand Up @@ -30,7 +30,8 @@ val readStructs: Iterable[ExampleStruct] = AvroFile.read[ExampleStruct](file)
Is this usable in production?
-----------------------------

Marley has been extracted from a project where it's been running successfully for a number of months.
Marley has been used successfully in the Guardian's realtime analytics system
Ophan for many years.

Marley is macro based and doesn't perform any runtime reflection. I haven't
done any micro-benchmarking, but it's currently serialising more than 5000
Expand Down
44 changes: 14 additions & 30 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
ThisBuild/scalaVersion := "2.13.12"
import sbtversionpolicy.withsbtrelease.ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease

ThisBuild/crossScalaVersions := Seq(scalaVersion.value)
ThisBuild / scalaVersion := "2.13.12"

val commonSettings = Seq(
organization := "com.gu",
homepage := Some(url("https://github.com/guardian/marley")),
licenses := Seq("Apache V2" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")),
licenses := Seq("Apache V2" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.twitter" %% "scrooge-core" % "22.12.0",
"org.apache.thrift" % "libthrift" % "0.17.0"
)
)

def versionDependent[T](scalaV: String, handlesAnnotations: Boolean, value: T):Option[T] = {
val preMacroAnnotationsScalaVersions = Set("2.11", "2.12")
Some(value).filter(_ => handlesAnnotations != preMacroAnnotationsScalaVersions.contains(scalaV))
}

lazy val core = project.settings(
name := "marley",
Compile / scalacOptions += versionDependent(scalaBinaryVersion.value, handlesAnnotations=true, "-Ymacro-annotations"),
libraryDependencies ++= versionDependent(scalaBinaryVersion.value, handlesAnnotations=false,
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)).toSeq ++ Seq(
Compile / scalacOptions ++= Seq("-release:11", "-Ymacro-annotations"),
libraryDependencies ++= Seq(
"org.apache.avro" % "avro" % "1.11.1",
"org.xerial.snappy" % "snappy-java" % "1.1.10.5",
"org.parboiled" %% "parboiled" % "2.5.0",
Expand All @@ -34,24 +27,20 @@ lazy val core = project.settings(
TestFrameworks.ScalaTest,
"-u", s"test-results/scala-${scalaVersion.value}"
)
).settings(commonSettings: _*).dependsOn(thriftExample % "test->test")

lazy val thriftExample = project.settings(commonSettings: _*)
).settings(commonSettings).dependsOn(thriftExample % "test->test")

Test/publishArtifact := false
lazy val thriftExample = project.settings(commonSettings).settings(
publish / skip := true,
)

lazy val root = (project in file(".")).aggregate(core).settings(
update/aggregate := false,
publishArtifact := false,
publish := {},
publishLocal := {}
update / aggregate := false,
publish / skip := true,
)

import ReleaseTransformations._
import sbt.Keys.scalaBinaryVersion

releaseCrossBuild := true // true if you cross-build the project for multiple Scala versions
import ReleaseTransformations.*

releaseVersion := fromAggregatedAssessedCompatibilityWithLatestRelease().value
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
Expand All @@ -60,11 +49,6 @@ releaseProcess := Seq[ReleaseStep](
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
commitNextVersion
)

2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ libraryDependencies += "org.apache.thrift" % "libthrift" % "0.17.0"
addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "22.12.0")

addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21")
25 changes: 0 additions & 25 deletions sonatype.sbt

This file was deleted.

0 comments on commit 3a31495

Please sign in to comment.