Skip to content

Commit

Permalink
Adopt GHA Scala Library Release Workflow
Browse files Browse the repository at this point in the history
[`gha-scala-library-release-workflow`](https://github.com/guardian/gha-scala-library-release-workflow) provides these benefits:

* **better security for release credentials** by isolating release phases into separate GitHub Workflow Jobs
* **removes a lot of sbt configuration** (`gha-scala-library-release-workflow` automatically provides sensible defaults)
* **automated version compatibility checking**, detecting binary & source incompatibilities, and setting SemVer-compliant version numbers appropriately - meaning that developers no longer have to assign version numbers, and sbt can now reliably detect when dependency eviction could cause runtime errors (see eg guardian/facia-scala-client#301 !) - and so block those problems at build time.

The configuration changes for adopting `gha-scala-library-release-workflow` are documented in [configuration.md](https://github.com/guardian/gha-scala-library-release-workflow/blob/main/docs/configuration.md) .
  • Loading branch information
rtyley committed Nov 22, 2024
1 parent 34e645a commit e9f423f
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 84 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
name: compile-test

name: CI
on:
workflow_dispatch:
pull_request:

# triggering CI default branch improves caching
# see https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
push:
branches:
- main

jobs:
build:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup Java 8
uses: actions/setup-java@v2
- name: Checkout
uses: actions/checkout@v4
- uses: guardian/setup-scala@v1
- name: Build and Test
run: sbt -v +test
- name: Test Summary
uses: test-summary/action@v2
with:
java-version: '8'
distribution: 'adopt'
- run: sbt test
paths: "test-results/**/TEST-*.xml"
if: always()
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@v1
permissions: { contents: write, pull-requests: write }
secrets:
SONATYPE_TOKEN: ${{ secrets.AUTOMATED_MAVEN_RELEASE_SONATYPE_TOKEN }}
PGP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_PGP_SECRET }}
GITHUB_APP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY }}
13 changes: 6 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@

*.class
test-results/
.DS_Store

# sbt specific
.cache
.history
.cache/
.history/
.lib/
.bsp/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/

.idea

# Scala-IDE specific
.scala_dependencies
.worksheet
.DS_Store
.idea
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java corretto-21.0.5.11.1
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

52 changes: 10 additions & 42 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import sbtrelease._
import ReleaseTransformations._
import ReleaseTransformations.*
import sbtversionpolicy.withsbtrelease.ReleaseVersion

name := "hmac-headers"

scalaVersion := "2.13.7"
scalaVersion := "3.3.4"

organization := "com.gu"

crossScalaVersions := Seq("2.11.8", "2.12.2", scalaVersion.value)
crossScalaVersions := Seq("2.12.20", "2.13.15", scalaVersion.value)

scmInfo := Some(ScmInfo(
url("https://github.com/guardian/hmac-headers"),
"scm:git:[email protected]:guardian/hmac-headers.git"
))

homepage := Some(url("https://github.com/guardian/hmac-headers"))
scalacOptions := Seq("-deprecation", "-release:11")

libraryDependencies ++= Seq(
"joda-time" % "joda-time" % "2.9.3",
Expand All @@ -24,34 +19,10 @@ libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.10" % "test"
)

pomExtra := (
<developers>
<developer>
<id>nlindblad</id>
<name>Niklas Lindblad</name>
<url>https://github.com/guardian/hmac-headers</url>
</developer>
<developer>
<id>emma-p</id>
<name>Emmanuelle Poirier</name>
<url>https://github.com/guardian/hmac-headers</url>
</developer>
</developers>)

publishMavenStyle := true
Test / publishArtifact := false
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))

publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

pomIncludeRepository := { _ => false }
licenses := Seq(License.Apache2)

// releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease().value,
releaseCrossBuild := true // true if you cross-build the project for multiple Scala versions
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
Expand All @@ -60,9 +31,6 @@ releaseProcess := Seq[ReleaseStep](
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(action = Command.process("publishSigned", _)),
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges
)
commitNextVersion
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.7
sbt.version=1.10.5
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logLevel := Level.Warn
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")

addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.10")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.11.3")

addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.1")

0 comments on commit e9f423f

Please sign in to comment.