diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d53425f..5b2e30a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,10 +12,13 @@ on: branches: ['*'] push: branches: ['*'] - tags: [v*] + tags: [v*, v*] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} jobs: build: @@ -37,44 +40,17 @@ jobs: with: java-version: ${{ matrix.java }} - - name: Cache ivy2 - uses: actions/cache@v1 - with: - path: ~/.ivy2/cache - key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (generic) - uses: actions/cache@v1 - with: - path: ~/.coursier/cache/v1 - key: ${{ runner.os }}-generic-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (linux) - if: contains(runner.os, 'linux') - uses: actions/cache@v1 - with: - path: ~/.cache/coursier/v1 - key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (macOS) - if: contains(runner.os, 'macos') - uses: actions/cache@v1 - with: - path: ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (windows) - if: contains(runner.os, 'windows') - uses: actions/cache@v1 - with: - path: ~/AppData/Local/Coursier/Cache/v1 - key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Cache sbt - uses: actions/cache@v1 + uses: actions/cache@v2 with: - path: ~/.sbt - key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + 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: Check that workflows are up to date run: sbt ++${{ matrix.scala }} githubWorkflowCheck @@ -121,44 +97,17 @@ jobs: with: java-version: ${{ matrix.java }} - - name: Cache ivy2 - uses: actions/cache@v1 - with: - path: ~/.ivy2/cache - key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (generic) - uses: actions/cache@v1 - with: - path: ~/.coursier/cache/v1 - key: ${{ runner.os }}-generic-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (linux) - if: contains(runner.os, 'linux') - uses: actions/cache@v1 - with: - path: ~/.cache/coursier/v1 - key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (macOS) - if: contains(runner.os, 'macos') - uses: actions/cache@v1 - with: - path: ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Cache coursier (windows) - if: contains(runner.os, 'windows') - uses: actions/cache@v1 - with: - path: ~/AppData/Local/Coursier/Cache/v1 - key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Cache sbt - uses: actions/cache@v1 + uses: actions/cache@v2 with: - path: ~/.sbt - key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + 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: Download target directories (2.12.12) uses: actions/download-artifact@v2 @@ -170,5 +119,7 @@ jobs: tar xf targets.tar rm targets.tar - - name: Release - run: sbt ++${{ matrix.scala }} ci-release \ No newline at end of file + - name: Import signing key + run: echo $PGP_SECRET | base64 -d | gpg --import + + - run: sbt ++${{ matrix.scala }} release \ No newline at end of file diff --git a/README.md b/README.md index dae4602..cd70556 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # sbt-http4s-org -This project is intended to set up sensible defaults and standards for projects in the http4s organization. -It is not designed for outside use, but we offer it as an inspiration or warning to others. +This project is intended to set up sensible defaults and standards for projects under http4s.org. +If it's useful outside http4s.org, it probably should be pushed further upstream into [sbt-spiewak](https://github.com/djspiewak/sbt-spiewak/). ## Installing it @@ -17,12 +17,9 @@ addSbtPlugin("org.http4s" % "sbt-http4s-org" % http4sOrgV) Triggers automatically. Use on all http4s modules. -* Sets the organization to `org.http4s` -* Sets `-Ybackend-parallelism` compiler option -* Sets an appropriate `-doc-source-url` for your Scaladoc +* Activates the sensible defaults of [sbt-spiewak](https://github.com/djspiewak/sbt-spiewak/) +* Sets the organization info * Enables automated SPDX license headers with appropriate years -* Enables [scalafmt](https://scalameta.org/scalafmt/) -* Enables [MiMa](https://github.com/lightbend/mima) checks for binary compatibility via [sbt-mima-version-check](https://christopherdavenport.github.io/sbt-mima-version-check/) * Enables [sbt-github-actions](https://github.com/djspiewak/sbt-github-actions) with settings appropriate to our workflow ### `AlpnBootPlugin` @@ -31,33 +28,3 @@ Enable with `enablePlugins(AlpnBootPlugin)`. Use on example projects that require ALPN support. * Sets up `-Xbootclasspath` for [ALPN](https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html). Useful primarily for example projects. - -### `CompileTimePlugin` - -Enable with `enablePlugins(CompileTimePlugin)`. -Mostly useful to support other plugins. - -* Sets up a `CompileTime` SBT configuration for libraries that exist at compile time, but not runtime. - -### `JavaPlugin` - -Enable with `enablePlugins(JavaPlugin)`. - -* Turns on `-Xlint:all` warnings -* Enables [sbt-java-formatter](https://github.com/sbt/sbt-java-formatter) - -### `PrivateProjectPlugin` - -Enable with `enablePlugins(PrivateProjectPlugin)`. -Use on examples, benchmarks, docs, and other projects that should not be published. - -* Skips publishing -* Disables MiMa checks. - -### `SilencerPlugin` - -Enable with `enablePlugins(SilencerPlugin)` - -* Adds the [silencer](https://github.com/ghik/silencer) compiler plugin to suppress warnings. -* Adds the supporting library to `CompileTime` and `Test` scopes, so it doesn't leave a trace in production. -* Disabled automatically in Dotty diff --git a/build.sbt b/build.sbt index c7ba273..11f3ac7 100644 --- a/build.sbt +++ b/build.sbt @@ -1,39 +1,29 @@ +enablePlugins(SonatypeCiRelease) + // Projects lazy val `sbt-http4s-org` = project .in(file(".")) - .disablePlugins(MimaPlugin) .enablePlugins(NoPublishPlugin) .aggregate(core) lazy val core = project .in(file("core")) .enablePlugins(SbtPlugin) - .settings(commonSettings) .settings( name := "sbt-http4s-org", - addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6"), - addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.9.4"), - addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16"), - addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.0"), - addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1"), - addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0"), - addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0"), - addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2"), + addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.18.3"), addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") ) -// General Settings -lazy val commonSettings = Seq( - scalaVersion := "2.12.12", - crossScalaVersions := Seq(scalaVersion.value), - libraryDependencies ++= Seq( - ) -) - // General Settings inThisBuild( List( organization := "org.http4s", + organizationName := "http4s.org", + publishGithubUser := "rossabaker", + publishFullName := "Ross A. Baker", + baseVersion := "0.5", + crossScalaVersions := Seq("2.12.12"), developers := List( Developer( "rossabaker", @@ -43,16 +33,6 @@ inThisBuild( ), homepage := Some(url("https://github.com/http4s/sbt-http4s-org")), licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), - pomIncludeRepository := { _ => - false - }, - scalacOptions in (Compile, doc) ++= Seq( - "-groups", - "-sourcepath", - (baseDirectory in LocalRootProject).value.getAbsolutePath, - "-doc-source-url", - "https://github.com/http4s/sbt-http4s-org/blob/v" + version.value + "€{FILE_PATH}.scala" - ), githubWorkflowTargetTags ++= Seq("v*"), githubWorkflowBuild := Seq( WorkflowStep @@ -61,7 +41,5 @@ inThisBuild( WorkflowStep.Sbt(List("test"), name = Some("Run tests")), WorkflowStep.Sbt(List("doc"), name = Some("Build docs")) ), - githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"), name = Some("Release"))), - githubWorkflowPublishTargetBranches := - Seq(RefPredicate.StartsWith(Ref.Tag("v"))) + spiewakMainBranches := Seq("main") )) diff --git a/core/src/main/scala/org/http4s/sbt/AlpnBootPlugin.scala b/core/src/main/scala/org/http4s/sbt/AlpnBootPlugin.scala index 3de7803..c50d235 100644 --- a/core/src/main/scala/org/http4s/sbt/AlpnBootPlugin.scala +++ b/core/src/main/scala/org/http4s/sbt/AlpnBootPlugin.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2020 http4s.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.http4s.sbt import sbt._ diff --git a/core/src/main/scala/org/http4s/sbt/CompileTimePlugin.scala b/core/src/main/scala/org/http4s/sbt/CompileTimePlugin.scala deleted file mode 100644 index a5fcf9b..0000000 --- a/core/src/main/scala/org/http4s/sbt/CompileTimePlugin.scala +++ /dev/null @@ -1,16 +0,0 @@ -package org.http4s.sbt - -import sbt._ -import sbt.Keys._ - -object CompileTimePlugin extends AutoPlugin { - object autoImport - - override lazy val projectSettings: Seq[Setting[_]] = - Seq( - ivyConfigurations += CompileTime, - unmanagedClasspath in Compile ++= update.value.select(configurationFilter("CompileTime")) - ) - - val CompileTime = config("CompileTime").hide -} diff --git a/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala b/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala index 0d05aef..5569ad5 100644 --- a/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala +++ b/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala @@ -1,31 +1,38 @@ +/* + * Copyright 2020 http4s.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.http4s.sbt import sbt._ import sbt.Keys._ -import com.typesafe.sbt.SbtGit.git -import dotty.tools.sbtplugin.DottyPlugin -import dotty.tools.sbtplugin.DottyPlugin.autoImport._ -import java.lang.{Runtime => JRuntime} -import _root_.io.chrisdavenport.sbtmimaversioncheck.MimaVersionCheck -import org.scalafmt.sbt.ScalafmtPlugin import sbtghactions._ import sbtghactions.GenerativeKeys._ +import sbtspiewak._, SonatypeCiRelease.autoImport._ object Http4sOrgPlugin extends AutoPlugin { object autoImport override def trigger = allRequirements - override def requires = - DottyPlugin && - MimaVersionCheck && - ScalafmtPlugin + override def requires = SpiewakPlugin && SonatypeCiRelease + + override def buildSettings = organizationSettings - override lazy val projectSettings: Seq[Setting[_]] = - organizationSettings ++ - scalaSettings ++ - docSettings + override def projectSettings = githubActionsSettings val organizationSettings: Seq[Setting[_]] = Seq( @@ -33,44 +40,10 @@ object Http4sOrgPlugin extends AutoPlugin { organizationName := "http4s.org" ) - val scalaSettings: Seq[Setting[_]] = - Seq( - scalacOptions ++= { - if (isDotty.value) Seq.empty - else - Seq( - "-Ybackend-parallelism", - math.min(JRuntime.getRuntime.availableProcessors, 16).toString - ) - } - ) - - val docSettings: Seq[Setting[_]] = - Seq( - Compile / doc / scalacOptions ++= { - (for { - headCommit <- git.gitHeadCommit.value - isSnapshot = git.gitCurrentTags.value.map(git.gitTagToVersionNumber.value).flatten.isEmpty - ref = if (isSnapshot) headCommit else s"v${version.value}" - scm <- scmInfo.value - browseUrl = scm.browseUrl - path = s"${browseUrl}/blob/${ref}€{FILE_PATH}.scala" - } yield Seq( - "-doc-source-url", - path, - "-sourcepath", - baseDirectory.in(LocalRootProject).value.getAbsolutePath - )).getOrElse(Seq.empty[String]) - } - ) - val githubActionsSettings: Seq[Setting[_]] = Seq( + spiewakMainBranches := Seq("main"), githubWorkflowJavaVersions := List("adopt@1.8", "adopt@1.11", "adopt@1.15"), - githubWorkflowTargetTags ++= Seq("v*"), - githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"), name = Some("Release"))), - githubWorkflowPublishTargetBranches := - Seq(RefPredicate.StartsWith(Ref.Tag("v"))), githubWorkflowBuild := Seq( WorkflowStep .Sbt(List("scalafmtCheckAll", "scalafmtSbtCheck"), name = Some("Check formatting")), diff --git a/core/src/main/scala/org/http4s/sbt/JavaPlugin.scala b/core/src/main/scala/org/http4s/sbt/JavaPlugin.scala deleted file mode 100644 index 70ce4ba..0000000 --- a/core/src/main/scala/org/http4s/sbt/JavaPlugin.scala +++ /dev/null @@ -1,19 +0,0 @@ -package org.http4s.sbt - -import sbt._ -import sbt.Keys._ - -import com.lightbend.sbt.JavaFormatterPlugin - -object JavaPlugin extends AutoPlugin { - object autoImport - - override def trigger = allRequirements - - override def requires = JavaFormatterPlugin - - override lazy val projectSettings: Seq[Setting[_]] = - Seq( - javacOptions += "-Xlint:all" - ) -} diff --git a/core/src/main/scala/org/http4s/sbt/PrivateProjectPlugin.scala b/core/src/main/scala/org/http4s/sbt/PrivateProjectPlugin.scala deleted file mode 100644 index be914b5..0000000 --- a/core/src/main/scala/org/http4s/sbt/PrivateProjectPlugin.scala +++ /dev/null @@ -1,18 +0,0 @@ -package org.http4s.sbt - -import com.typesafe.tools.mima.plugin.MimaPlugin -import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport.mimaPreviousArtifacts -import sbt._ -import sbt.Keys._ - -object PrivateProjectPlugin extends AutoPlugin { - override def trigger = noTrigger - - override def requires = Http4sOrgPlugin && MimaPlugin - - override lazy val projectSettings: Seq[Setting[_]] = - Seq( - publish / skip := true, - mimaPreviousArtifacts := Set.empty - ) -} diff --git a/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala b/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala deleted file mode 100644 index 7ef74b8..0000000 --- a/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala +++ /dev/null @@ -1,39 +0,0 @@ -package org.http4s.sbt - -import sbt._ -import sbt.Keys._ - -import dotty.tools.sbtplugin.DottyPlugin -import dotty.tools.sbtplugin.DottyPlugin.autoImport._ -import explicitdeps.ExplicitDepsPlugin.autoImport._ -import CompileTimePlugin.CompileTime - -object SilencerPlugin extends AutoPlugin { - object autoImport { - val silencerVersion = settingKey[String]("Version of the silencer compiler plugin") - } - - import autoImport._ - - override def trigger = allRequirements - override def requires = DottyPlugin && CompileTimePlugin - - override lazy val projectSettings: Seq[Setting[_]] = - Seq( - silencerVersion := "1.7.0", - libraryDependencies ++= { - if (isDotty.value) Seq.empty - else - Seq( - compilerPlugin( - ("com.github.ghik" % "silencer-plugin" % silencerVersion.value).cross( - CrossVersion.full)), - ("com.github.ghik" % "silencer-lib" % silencerVersion.value % CompileTime) - .cross(CrossVersion.full), - ("com.github.ghik" % "silencer-lib" % silencerVersion.value % Test) - .cross(CrossVersion.full) - ) - }, - unusedCompileDependenciesFilter -= moduleFilter("com.github.ghik", name = "silencer-lib") - ) -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 2f50ba8..0f0eabb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,2 @@ -addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.9.4") -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.4") -addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2") -addSbtPlugin("io.chrisdavenport" % "sbt-no-publish" % "0.1.0") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16") +addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.18.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")