diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0ec16c9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + # keeps the commit-pinned actions in the workflows up to date, updating the version comments too + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + # give the ecosystem a week to catch a compromised release before it gets proposed here + cooldown: + default-days: 7 + # one PR for all the actions instead of one per action + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f877fc..87a013e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,21 +5,26 @@ on: branches: [ main ] pull_request: +permissions: + contents: read + jobs: - build: + ci-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - # fetch tags - tags are needed for versionPolicyCheck binary and source compat checks - fetch-tags: true - - uses: coursier/cache-action@v6 - # SBT 1 base JDK version is 1.8 - - uses: actions/setup-java@v5 + # Fetch all history for all branches and tags. + # Tags are needed for versionPolicyCheck binary and source compat checks. + # In a shallow clone the previous release tag isn't reachable from HEAD and the checks are silently skipped. + fetch-depth: 0 + persist-credentials: false + - uses: coursier/cache-action@ee0650f98295f27a505e4bfd284c9bfaa913a465 # v9.0.1 + - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 with: - java-version: 8 + java-version-file: .java-version distribution: temurin cache: sbt - - uses: sbt/setup-sbt@v1 + - uses: sbt/setup-sbt@b113b960ba361e87e08ce02a390d51871b7ee459 # v1.5.13 - name: sbt build run: sbt clean buildFull diff --git a/.github/workflows/dependency-graph.yml b/.github/workflows/dependency-graph.yml index 2962e8d..7a26633 100644 --- a/.github/workflows/dependency-graph.yml +++ b/.github/workflows/dependency-graph.yml @@ -9,4 +9,4 @@ permissions: jobs: submit: - uses: evolution-gaming/scala-github-actions/.github/workflows/dependency-graph.yml@2a50f1819b6fef2657ba802fd62612b7fc8450f0 # v6.4.0 + uses: evolution-gaming/scala-github-actions/.github/workflows/dependency-graph.yml@144b8762ece97a25b24621f9d470542fa1e068b4 # v7.2.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0dd9ff1..3d9451c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,40 +4,59 @@ on: push: tags: [ "v*" ] +# deleting the release tag and creating the GitHub release both need write access +permissions: + contents: write + # run only one release action at a time for the repo, wait for the previous to finish before running another one concurrency: group: ${{ github.repository }}-${{ github.workflow }} + # by default only one run can be pending, an older pending run gets cancelled and leaves its tag behind + queue: max jobs: publish: runs-on: ubuntu-latest + # a timed out job is cancelled instead of hanging for the default 6 hours, + # see the tag deletion step for what happens to the release tag then + timeout-minutes: 90 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # Fetch all history for all branches and tags - just in case it's all necessary for ci-release. # Tags are needed for versionPolicyCheck binary and source compat checks. fetch-depth: 0 - - uses: coursier/cache-action@v6 - # SBT 1 base JDK version is 1.8 - - uses: actions/setup-java@v5 + # don't leave the write token in the git config where the build and its plugins can read it + persist-credentials: false + # No dependency caches here: caches written by main branch CI runs are restorable by tag runs, + # so anything that gets to run in CI could plant code into the job holding the publishing secrets. + - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 with: - java-version: 8 + java-version-file: .java-version distribution: temurin - cache: sbt - - uses: sbt/setup-sbt@v1 + # setup-sbt has no option to disable restoring the sbt runner itself from the cache + - uses: sbt/setup-sbt@b113b960ba361e87e08ce02a390d51871b7ee459 # v1.5.13 + with: + disk-cache: false # sbt ci-release doesn't verify the build, need to do it explicitly - name: sbt build run: sbt clean buildFull - - run: sbt ci-release + - id: ci-release + run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + # A cancellation (manual or by the timeout) during sbt ci-release can come after the bundle got uploaded, + # and Maven Central then publishes the version anyway - the tag is kept to point at the published commit. - name: delete release tag if failed - if: failure() - run: git push --delete origin ${{ github.ref_name }} + if: failure() || (cancelled() && steps.ci-release.outcome == 'skipped') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: gh api --method DELETE "repos/$GITHUB_REPOSITORY/git/refs/tags/$tag" - name: publish release notes if: success() diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..98d9bcb --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17 diff --git a/.scalafmt.conf b/.scalafmt.conf index f5c48ca..6d1a24b 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -3,7 +3,7 @@ # - better interop with default IntelliJ IDEA setup (matching import and modifiers sorting logic) # - better developer experience on laptop screens (like 16' MBPs) with IntelliJ IDEA (line wraps) -version = 3.9.9 +version = 3.11.5 runner.dialect = scala213source3 fileOverride { diff --git a/README.md b/README.md index 624fbe0..add84a1 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ SBT version support: | Supported major SBT version | Built against concrete SBT Version | Build JDK version | |-----------------------------|------------------------------------|-------------------| -| 1 | 1.4.5 | 1.8 | -| 2 | 2.0.0-RC6 | 1.8 | +| 1 | 1.2.15 | 17 | +| 2 | 2.0.12 | 17 | If your SBT version is earlier than the build SBT version, the plugin might still work, but the support is not guaranteed. @@ -148,7 +148,7 @@ create your own custom rules. ### Build Requirements -The GitHub Actions CI build is done using JDK 1.8, but locally you can use any JDK up to 17 (including). +JDK 17 and sbt installed. ### Useful SBT commands diff --git a/build.sbt b/build.sbt index 9e2651f..872b0d5 100644 --- a/build.sbt +++ b/build.sbt @@ -35,48 +35,57 @@ versionPolicyIntention := Compatibility.BinaryCompatible // setting up sbt 1 and 2 cross-build // https://www.scala-sbt.org/2.x/docs/en/changes/migrating-from-sbt-1.x.html#cross-building-sbt-plugin-with-sbt-1x -crossScalaVersions += "3.7.3" // version used by SBT 2.0.0-RC6 +crossScalaVersions += "3.8.4" // version used by SBT 2.0.12 pluginCrossBuild / sbtVersion := { scalaBinaryVersion.value match { - // set minimal supported sbt 1 version - // pre 1.4.5 sbt doesn't work on M1 macs: https://github.com/sbt/sbt/issues/6162 - case "2.12" => "1.4.5" - case "3" => "2.0.0-RC6" + case "2.12" => "1.12.15" + case "3" => "2.0.12" } } // scalac and scaladoc options autoAPIMappings := true -scalacOptions ++= Seq( - "-release:8", // increase the version here if sbt 2 changes min JDK reqs - "-deprecation", -) -scalacOptions ++= crossSettings( - scalaVersion = scalaVersion.value, - if2 = Seq( - "-Xsource:3", - ), - // Good compiler options for Scala 2.12 are coming from com.evolution:sbt-scalac-opts-plugin:0.0.9, - // but its support for Scala 3 is limited, especially what concerns linting options. - // - // If Scala 3 is made the primary target, good linting scalac options for it should be added first. - if3 = Seq( - "-Xkind-projector:underscores", +scalacOptions := { + val curOptions = scalacOptions.value - // disable new brace-less syntax: - // https://alexn.org/blog/2022/10/24/scala-3-optional-braces/ - "-no-indent", + scalaBinaryVersion.value match { + case "2.12" => + // options for 2.12 come mostly from com.evolution:sbt-scalac-opts-plugin + curOptions ++ Seq( + "-Xsource:3", + ) - // improve error messages: - "-explain", - "-explain-types", - ), + case "3" => + // Discarding scalacOptions coming from com.evolution:sbt-scalac-opts-plugin, + // because it adds an option which fails compilation on 3.8.x: + // + // [warn] Option -Xfatal-warnings is a deprecated alias: use -Werror instead + // [error] No warnings can be incurred under -Werror + // [warn] one warning found + // [error] one error found + Seq( + "-Xkind-projector:underscores", + + // disable new brace-less syntax: + // https://alexn.org/blog/2022/10/24/scala-3-optional-braces/ + "-no-indent", + + // improve error messages: + "-explain", + "-explain-types", + ) + } +} +// common options +scalacOptions ++= Seq( + "-release:17", // sbt 2 requires JDK 17+ + "-deprecation", ) // migesok: tried several test frameworks, but only munit worked here: // - scalatest with AnyFreeSpec gave weird compilation errors on valid test code // - utest 0.9.1 didn't work on Java 8, only 11+, but Java 8 is required for sbt 1 -libraryDependencies += "org.scalameta" %% "munit" % "1.2.0" % Test +libraryDependencies += "org.scalameta" %% "munit" % "1.3.6" % Test // disable parallel test execution and bufferization to have nice linear stdout: // https://scalameta.org/munit/docs/tests.html#run-tests-in-parallel Test / parallelExecution := false diff --git a/project/build.properties b/project/build.properties index 01a16ed..3686073 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.11.7 +sbt.version=1.13.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index 7b7c3b4..30edcbc 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.0.9") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5") -addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.1") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2") +addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.2.1") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.2") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.4.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.12.1")