From c87feaf3334971594056acb9682234a2af1ac546 Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Thu, 15 Feb 2024 09:10:05 +1100 Subject: [PATCH] Target JDK 1.8 and use sbt-github-actions for snapshot publish --- .github/workflows/ci.yml | 82 +++++++++++++++++++++++++++-------- .github/workflows/publish.yml | 33 -------------- build.sbt | 21 ++++++--- project/plugins.sbt | 3 +- 4 files changed, 81 insertions(+), 58 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15c59f5..516b291 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] scala: [2.12.18] - java: [temurin@11, temurin@17, temurin@21] + java: [temurin@8] runs-on: ${{ matrix.os }} steps: - name: Ignore line ending differences in git @@ -45,33 +45,79 @@ jobs: with: fetch-depth: 0 - - name: Setup Java (temurin@11) - if: matrix.java == 'temurin@11' + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' uses: actions/setup-java@v4 with: distribution: temurin - java-version: 11 + java-version: 8 cache: sbt - - name: Setup Java (temurin@17) - if: matrix.java == 'temurin@17' - uses: actions/setup-java@v4 + - name: Check that workflows are up to date + shell: bash + run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck + + - shell: bash + run: sbt '++ ${{ matrix.scala }}' test scripted + + - name: Compress target directories + shell: bash + run: tar cf targets.tar target theme/target plugin/target project/target + + - name: Upload target directories + uses: actions/upload-artifact@v4 with: - distribution: temurin - java-version: 17 - cache: sbt + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main') + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.18] + java: [temurin@8] + runs-on: ${{ matrix.os }} + steps: + - name: Ignore line ending differences in git + if: contains(runner.os, 'windows') + run: git config --global core.autocrlf false - - name: Setup Java (temurin@21) - if: matrix.java == 'temurin@21' + - name: Configure pagefile for Windows + if: contains(runner.os, 'windows') + uses: al-cheb/configure-pagefile-action@v1.4 + with: + minimum-size: 2GB + maximum-size: 8GB + disk-root: 'C:' + + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' uses: actions/setup-java@v4 with: distribution: temurin - java-version: 21 + java-version: 8 cache: sbt - - name: Check that workflows are up to date - shell: bash - run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck + - name: Download target directories (2.12.18) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-2.12.18-${{ matrix.java }} - - shell: bash - run: sbt '++ ${{ matrix.scala }}' test scripted + - name: Inflate target directories (2.12.18) + run: | + tar xf targets.tar + rm targets.tar + + - name: Publish project + env: + NEXUS_USER: ${{ secrets.NEXUS_USER }} + NEXUS_PW: ${{ secrets.NEXUS_PW }} + run: sbt publish diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 8501eca..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Publish - -on: - push: - branches: [ "main" ] - -jobs: - sbt: - name: Publish to apache nexus - runs-on: ubuntu-20.04 - if: github.repository == 'apache/incubator-pekko-sbt-paradox' - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: 0 - - - name: Setup Java 8 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 8 - - - name: Cache Coursier cache - uses: coursier/cache-action@v6 - - - name: Publish - run: |- - sbt publish - env: - NEXUS_USER: ${{ secrets.NEXUS_USER }} - NEXUS_PW: ${{ secrets.NEXUS_PW }} diff --git a/build.sbt b/build.sbt index fa0c232..2d39fc3 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,10 @@ import net.bzzt.reproduciblebuilds.ReproducibleBuildsPlugin.reproducibleBuildsCheckResolver -scalaVersion := "2.13.11" +val scala212 = "2.12.18" + +ThisBuild / scalaVersion := scala212 +ThisBuild / crossScalaVersions := Seq(scala212) ThisBuild / apacheSonatypeProjectProfile := "pekko" ThisBuild / dynverSonatypeSnapshots := true @@ -88,12 +91,18 @@ lazy val pekkoPlugin = project ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted"))) ThisBuild / githubWorkflowTargetTags ++= Seq("v*") -ThisBuild / githubWorkflowPublishTargetBranches := Seq() -ThisBuild / githubWorkflowPublish := Seq() +ThisBuild / githubWorkflowPublishTargetBranches := Seq( + RefPredicate.Equals(Ref.Branch("main"))) + +ThisBuild / githubWorkflowPublish := Seq( + WorkflowStep.Sbt( + commands = List("publish"), + name = Some("Publish project"), + env = Map( + "NEXUS_USER" -> "${{ secrets.NEXUS_USER }}", + "NEXUS_PW" -> "${{ secrets.NEXUS_PW }}"))) ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest", "windows-latest") ThisBuild / githubWorkflowJavaVersions := Seq( - JavaSpec.temurin("11"), - JavaSpec.temurin("17"), - JavaSpec.temurin("21")) + JavaSpec.temurin("8")) diff --git a/project/plugins.sbt b/project/plugins.sbt index 1415324..9f220ed 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -17,7 +17,8 @@ // When updating the sbt-paradox version, // remember to also update build.sbt -addSbtPlugin("com.lightbend.paradox" % "sbt-paradox-theme" % "0.10.6") +addSbtPlugin("com.lightbend.paradox" % "sbt-paradox-theme" % "0.9.2") +addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") addSbtPlugin("org.mdedetrich" % "sbt-apache-sonatype" % "0.1.10")