From a6c07e0c21efd53021fe25fe87c5d7f05cc687fb Mon Sep 17 00:00:00 2001
From: Matthew de Detrich <matthew.dedetrich@aiven.io>
Date: Fri, 17 May 2024 16:10:18 +0200
Subject: [PATCH] Add macos-latest to workflow

---
 .github/workflows/ci.yml |  9 ++++++++-
 build.sbt                | 16 +++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1ff50f5..3be244e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -22,9 +22,12 @@ jobs:
     name: Build and Test
     strategy:
       matrix:
-        os: [ubuntu-latest, macos-12]
+        os: [ubuntu-latest, macos-12, macos-latest]
         scala: [2.12.19, 2.13.13, 3.3.3]
         java: [temurin@8, temurin@11, temurin@17, temurin@21]
+        exclude:
+          - java: temurin@8
+            os: macos-latest
     runs-on: ${{ matrix.os }}
     steps:
       - name: Checkout current branch (full)
@@ -64,6 +67,10 @@ jobs:
           java-version: 21
           cache: sbt
 
+      - name: Install sbt
+        if: matrix.os == 'macos-latest'
+        run: brew install sbt
+
       - name: Check that workflows are up to date
         run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
 
diff --git a/build.sbt b/build.sbt
index ab08400..262e36e 100644
--- a/build.sbt
+++ b/build.sbt
@@ -198,7 +198,7 @@ ThisBuild / githubWorkflowPublishTargetBranches :=
     RefPredicate.Equals(Ref.Branch("main"))
   )
 
-ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-12")
+ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-12", "macos-latest")
 
 ThisBuild / githubWorkflowJavaVersions := List(
   JavaSpec.temurin("8"),
@@ -206,3 +206,17 @@ ThisBuild / githubWorkflowJavaVersions := List(
   JavaSpec.temurin("17"),
   JavaSpec.temurin("21")
 )
+
+ThisBuild / githubWorkflowBuildMatrixExclusions +=
+  MatrixExclude(Map("java" -> "temurin@8", "os" -> "macos-latest"))
+
+// GitHub Actions macOS 13+ runner images do not come with sbt preinstalled anymore
+ThisBuild / githubWorkflowBuildPreamble ++= Seq(
+  WorkflowStep.Run(
+    commands = List(
+      "brew install sbt"
+    ),
+    cond = Some("matrix.os == 'macos-latest'"),
+    name = Some("Install sbt")
+  )
+)