Skip to content

Commit

Permalink
Merge pull request #120 from armanbilge/topic/sbt-typelevel
Browse files Browse the repository at this point in the history
Migrate to sbt-typelevel and self-host
  • Loading branch information
rossabaker authored Jan 18, 2022
2 parents 5a8773f + b1f2429 commit 3d8be9e
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 92 deletions.
73 changes: 57 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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)
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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:
Expand All @@ -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
53 changes: 12 additions & 41 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enablePlugins(SonatypeCiReleasePlugin)
enablePlugins(TypelevelCiReleasePlugin)

// Projects
lazy val `sbt-http4s-org` = project
Expand All @@ -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)
2 changes: 2 additions & 0 deletions core/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.0-M4")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16")
40 changes: 7 additions & 33 deletions core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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')"))
)
)
}
1 change: 1 addition & 0 deletions project/Http4sOrgPlugin.scala
1 change: 1 addition & 0 deletions project/core.sbt
2 changes: 0 additions & 2 deletions project/plugins.sbt

This file was deleted.

0 comments on commit 3d8be9e

Please sign in to comment.