diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7473c9c..db02d31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,55 +16,70 @@ on: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +concurrency: + group: ${{ github.workflow }} @ ${{ github.ref }} + cancel-in-progress: true + jobs: build: - name: Build and Test + name: Test strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-22.04] scala: [2.12.15, 2.11.12, 2.13.8, 3.0.2] java: [temurin@8, temurin@11, temurin@17] runs-on: ${{ matrix.os }} + timeout-minutes: 60 steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Setup sbt + uses: sbt/setup-sbt@v1 + - name: Setup Java (temurin@8) + id: setup-java-temurin-8 if: matrix.java == 'temurin@8' - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 8 + cache: sbt + + - name: sbt update + if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false' + run: sbt +update - name: Setup Java (temurin@11) + id: setup-java-temurin-11 if: matrix.java == 'temurin@11' - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 11 + cache: sbt + + - name: sbt update + if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false' + run: sbt +update - name: Setup Java (temurin@17) + id: setup-java-temurin-17 if: matrix.java == 'temurin@17' - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 + cache: sbt - - name: Cache sbt - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.coursier/cache/v1 - ~/.cache/coursier/v1 - ~/AppData/Local/Coursier/Cache/v1 - ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + - name: sbt update + if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false' + run: sbt +update - name: Check that workflows are up to date - run: sbt ++${{ matrix.scala }} githubWorkflowCheck + run: sbt githubWorkflowCheck - - run: sbt ++${{ matrix.scala }} testIfRelevant mimaReportBinaryIssues + - run: sbt '++ ${{ matrix.scala }}' testIfRelevant mimaReportBinaryIssues diff --git a/build.sbt b/build.sbt index af16efe..d3d3cb7 100644 --- a/build.sbt +++ b/build.sbt @@ -13,6 +13,21 @@ lazy val binaryCompatStep = releaseStepCommandAndRemaining("+mimaReportBinaryIss lazy val testIfRelevantStep = releaseStepCommandAndRemaining("+testIfRelevant") lazy val publishIfRelevantStep = releaseStepCommandAndRemaining("+publishSignedIfRelevant") +// sonaReleaseIfNecessary is from sbt-typelevel +// https://github.com/typelevel/sbt-typelevel/blob/v0.8.0/sonatype/src/main/scala/org/typelevel/sbt/TypelevelSonatypePlugin.scala#L81-L87 +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2022 Typelevel +lazy val sonaReleaseIfNecessary: Command = + Command.command("sonaReleaseIfNecessary") { state => + if (state.getSetting(isSnapshot).getOrElse(false)) + state // a snapshot is good-to-go + else // a non-snapshot releases as a bundle + Command.process("sonaRelease", state, _ => ()) + } + +commands += sonaReleaseIfNecessary +lazy val sonaReleaseIfNecessaryStep = releaseStepCommand("sonaReleaseIfNecessary") + /* This is the standard release process plus a binary compat check after tests */ releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, @@ -24,6 +39,7 @@ releaseProcess := Seq[ReleaseStep]( commitReleaseVersion, tagRelease, publishIfRelevantStep, + sonaReleaseIfNecessaryStep, setNextVersion, commitNextVersion, pushChanges diff --git a/project/BasicSettings.scala b/project/BasicSettings.scala index 68fafa4..169ebb1 100644 --- a/project/BasicSettings.scala +++ b/project/BasicSettings.scala @@ -61,13 +61,6 @@ trait BasicSettings extends ProjectSettings { st: SettingTemplate => } else { Seq.empty } - ) ++ ( - if (sonatypeResolver) { - /* Many OSS projects push here and then appear in Maven Central later */ - Seq(resolvers += Resolver.sonatypeRepo("releases")) - } else { - Seq.empty - } ) ) diff --git a/project/Publish.scala b/project/Publish.scala index 77ac683..5b7f909 100644 --- a/project/Publish.scala +++ b/project/Publish.scala @@ -1,8 +1,7 @@ -import sbt._ +import sbt.{Resolvers => _, _} import Keys._ object Publish { - import Resolvers._ import Helpers._ val sonaCreds = ( @@ -12,7 +11,7 @@ object Publish { } yield { credentials += Credentials("Sonatype Nexus Repository Manager", - "oss.sonatype.org", + "central.sonatype.com", user, pass) } ).toSeq @@ -23,10 +22,9 @@ object Publish { Test / publishArtifact := false, publishTo := { - if (version.value.trim endsWith "SNAPSHOT") - Some(sonatypeSnaps) - else - Some(sonatypeStaging) + val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/" + if (isSnapshot.value) Some("central-snapshots" at centralSnapshots) + else localStaging.value }, pomExtra := BasicSettings.developerInfo diff --git a/project/Resolvers.scala b/project/Resolvers.scala deleted file mode 100644 index fe0db2d..0000000 --- a/project/Resolvers.scala +++ /dev/null @@ -1,8 +0,0 @@ -import sbt._ - -object Resolvers { - val sonatypeSnaps = Resolver.sonatypeRepo("snapshots") - val sonatypeRelease = Resolver.sonatypeRepo("releases") - val sonatypeStaging = "Sonatype Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2" -} - diff --git a/project/build.properties b/project/build.properties index c8fcab5..bbb0b60 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.2 +sbt.version=1.11.2 diff --git a/project/plugin-github-actions.sbt b/project/plugin-github-actions.sbt index ab75c56..9ffab92 100644 --- a/project/plugin-github-actions.sbt +++ b/project/plugin-github-actions.sbt @@ -1 +1 @@ -addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") +addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.8.0") diff --git a/project/plugin-sonatype.sbt b/project/plugin-sonatype.sbt deleted file mode 100644 index ca0878e..0000000 --- a/project/plugin-sonatype.sbt +++ /dev/null @@ -1,4 +0,0 @@ -/* Plugin that provides connectivity to the Sonatype repo, where many open - * source projects are hosted. (Projects published here are automatically - * synchronized to Maven central.) */ -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5") diff --git a/version.sbt b/version.sbt index 2bd148c..c835ac8 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "1.10.1-SNAPSHOT" +ThisBuild / version := "1.10.1-SNAPSHOT"