diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9e96f6..f2d1d2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,11 @@ on: branches: ['**'] push: branches: ['**'] - tags: [v*, v*] + tags: [v*] env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - JABBA_INDEX: 'https://github.com/typelevel/jdk-index/raw/main/index.json' SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} PGP_SECRET: ${{ secrets.PGP_SECRET }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -25,10 +25,11 @@ jobs: build: name: Build and Test strategy: + fail-fast: false matrix: os: [ubuntu-latest] scala: [2.12.15] - java: [temurin@8] + java: [temurin@8, temurin@11, temurin@17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -43,6 +44,20 @@ jobs: distribution: temurin java-version: 8 + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 11 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 17 + - name: Cache sbt uses: actions/cache@v2 with: @@ -56,22 +71,25 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Check that workflows are up to date - run: sbt ++${{ matrix.scala }} githubWorkflowCheck + run: sbt '++${{ matrix.scala }}' 'project /' githubWorkflowCheck + + - name: Check headers and formatting + run: sbt '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck - - name: Check formatting - run: sbt ++${{ matrix.scala }} scalafmtCheckAll scalafmtSbtCheck + - name: Test + run: sbt '++${{ matrix.scala }}' test - - name: Check headers - run: sbt ++${{ matrix.scala }} headerCheckAll + - name: Check binary compatibility + run: sbt '++${{ matrix.scala }}' mimaReportBinaryIssues - - name: Compile - run: 'sbt ++${{ matrix.scala }} test:compile' + - name: Generate API documentation + run: sbt '++${{ matrix.scala }}' doc - - name: Run tests - run: sbt ++${{ matrix.scala }} test + - name: Check unused compile dependencies + run: sbt '++${{ matrix.scala }}' unusedCompileDependenciesTest - - name: Build docs - run: sbt ++${{ matrix.scala }} doc + - name: Make target directories + run: mkdir -p target core/target project/target - name: Compress target directories run: tar cf targets.tar target core/target project/target @@ -85,7 +103,7 @@ jobs: publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') strategy: matrix: os: [ubuntu-latest] @@ -105,6 +123,20 @@ jobs: distribution: temurin java-version: 8 + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 11 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 17 + - name: Cache sbt uses: actions/cache@v2 with: @@ -128,6 +160,15 @@ jobs: rm targets.tar - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' run: echo $PGP_SECRET | base64 -d | gpg --import - - run: sbt ++${{ matrix.scala }} release + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -d > /tmp/signing-key.gpg + echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg + (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1) + + - name: Publish + run: sbt '++${{ matrix.scala }}' tlRelease diff --git a/build.sbt b/build.sbt index 428b6a6..da0f402 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -enablePlugins(SonatypeCiReleasePlugin) +enablePlugins(TypelevelCiReleasePlugin) // Projects lazy val `sbt-http4s-org` = project @@ -10,45 +10,16 @@ lazy val core = project .in(file("core")) .enablePlugins(SbtPlugin) .settings( - name := "sbt-http4s-org", - addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0"), - addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") + name := "sbt-http4s-org" ) -// General Settings -inThisBuild( - List( - organization := "org.http4s", - organizationName := "http4s.org", - publishGithubUser := "rossabaker", - publishFullName := "Ross A. Baker", - baseVersion := "0.7", - crossScalaVersions := Seq("2.12.15"), - developers := List( - Developer( - "rossabaker", - "Ross A. Baker", - "ross@rossabaker.com", - url("https://github.com/rossabaker")) - ), - homepage := Some(url("https://github.com/http4s/sbt-http4s-org")), - scmInfo := Some( - ScmInfo( - url("https://github.com/http4s/sbt-http4s-org.git"), - "git@github.com:http4s/sbt-http4s-org.git")), - startYear := Some(2020), - licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), - githubWorkflowTargetTags ++= Seq("v*"), - githubWorkflowBuild := Seq( - WorkflowStep - .Sbt(List("scalafmtCheckAll", "scalafmtSbtCheck"), name = Some("Check formatting")), - WorkflowStep - .Sbt(List("headerCheckAll"), name = Some("Check headers")), - WorkflowStep.Sbt(List("test:compile"), name = Some("Compile")), - WorkflowStep.Sbt(List("test"), name = Some("Run tests")), - WorkflowStep.Sbt(List("doc"), name = Some("Build docs")) - ), - githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8")), - githubWorkflowEnv += ("JABBA_INDEX" -> "https://github.com/typelevel/jdk-index/raw/main/index.json"), - spiewakMainBranches := Seq("main") - )) +ThisBuild / tlBaseVersion := "0.10" +ThisBuild / crossScalaVersions := Seq("2.12.15") +ThisBuild / developers := List( + Developer( + "rossabaker", + "Ross A. Baker", + "ross@rossabaker.com", + url("https://github.com/rossabaker")) +) +ThisBuild / startYear := Some(2020) diff --git a/core/build.sbt b/core/build.sbt new file mode 100644 index 0000000..11b7cad --- /dev/null +++ b/core/build.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.0-M4") +addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") diff --git a/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala b/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala index 7a4adbf..73307f2 100644 --- a/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala +++ b/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala @@ -19,19 +19,18 @@ package org.http4s.sbt import sbt._ import sbt.Keys._ -import com.typesafe.sbt.SbtGit.git -import sbtghactions._ -import sbtghactions.GenerativeKeys._ -import sbtspiewak._, SonatypeCiReleasePlugin.autoImport._ +import explicitdeps.ExplicitDepsPlugin +import org.typelevel.sbt.gha._, GenerativeKeys._ +import org.typelevel.sbt._ object Http4sOrgPlugin extends AutoPlugin { object autoImport override def trigger = allRequirements - override def requires = SpiewakPlugin && SonatypeCiReleasePlugin + override def requires = TypelevelPlugin && ExplicitDepsPlugin - override def buildSettings = organizationSettings ++ githubActionsSettings ++ http4sStyleSnapshots + override def buildSettings = organizationSettings ++ githubActionsSettings val organizationSettings: Seq[Setting[_]] = Seq( @@ -41,39 +40,14 @@ object Http4sOrgPlugin extends AutoPlugin { val githubActionsSettings: Seq[Setting[_]] = Seq( - spiewakMainBranches := Seq("main"), githubWorkflowJavaVersions := List("8", "11", "17").map(JavaSpec.temurin(_)), - githubWorkflowEnv += ("JABBA_INDEX" -> "https://github.com/typelevel/jdk-index/raw/main/index.json"), - githubWorkflowBuild := Seq( - WorkflowStep - .Sbt(List("scalafmtCheckAll", "scalafmtSbtCheck"), name = Some("Check formatting")), - WorkflowStep.Sbt(List("headerCheckAll"), name = Some("Check headers")), - WorkflowStep.Sbt(List("test:compile"), name = Some("Compile")), - WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Check binary compatibility")), + githubWorkflowBuildPostamble ++= Seq( WorkflowStep.Sbt( List("unusedCompileDependenciesTest"), - name = Some("Check unused compile dependencies")), - WorkflowStep.Sbt(List("test"), name = Some("Run tests")), - WorkflowStep.Sbt(List("doc"), name = Some("Build docs")) + name = Some("Check unused compile dependencies")) ), githubWorkflowBuildMatrixFailFast := Some(false), - githubWorkflowArtifactUpload := false, githubWorkflowTargetBranches := Seq("**") ) - val http4sStyleSnapshots: Seq[Setting[_]] = - Seq( - isSnapshot := - git.gitCurrentTags.value.isEmpty || git.gitUncommittedChanges.value, - version := { - val v = version.value - val suffix = "-SNAPSHOT" - if (isSnapshot.value && !v.endsWith(suffix)) v + suffix else v - }, - githubWorkflowPublish := Seq( - WorkflowStep.Sbt(List("+publish")), - WorkflowStep - .Sbt(List("sonatypeBundleRelease"), cond = Some("startsWith(github.ref, 'refs/tags/v')")) - ) - ) } diff --git a/project/Http4sOrgPlugin.scala b/project/Http4sOrgPlugin.scala new file mode 120000 index 0000000..b1f7751 --- /dev/null +++ b/project/Http4sOrgPlugin.scala @@ -0,0 +1 @@ +../core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala \ No newline at end of file diff --git a/project/core.sbt b/project/core.sbt new file mode 120000 index 0000000..f24fe19 --- /dev/null +++ b/project/core.sbt @@ -0,0 +1 @@ +../core/build.sbt \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index d36d4ab..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1,2 +0,0 @@ -addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")