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

Adopt scala library release GHA workflow #102

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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.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.