Skip to content

Commit

Permalink
Merge pull request #169 from rpiaggio/github-actions
Browse files Browse the repository at this point in the history
Remove publish settings handled by sbt-ci-release.
  • Loading branch information
ChristopherDavenport authored Aug 20, 2020
2 parents bfa41a8 + 1f1403f commit ddf854a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 145 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ jobs:
path: ~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('build.sbt') }}
restore-keys: ${{ runner.os }}-sbt-
- name: Run sbt tasks
run: csbt ++$SCALA_VERSION test:compile mimaReportBinaryIssues test doc
- name: Compile
run: csbt ++$SCALA_VERSION test:compile
#- name: Check compatibility
# run: csbt ++$SCALA_VERSION mimaReportBinaryIssues
- name: Test
run: csbt ++$SCALA_VERSION test
- name: Scaladoc
run: csbt ++$SCALA_VERSION doc
docs:
name: Doc Site
runs-on: ubuntu-latest
Expand Down
159 changes: 27 additions & 132 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
lazy val `cats-time` = project
.in(file("."))
.disablePlugins(MimaPlugin)
.settings(commonSettings, releaseSettings, skipOnPublishSettings)
.enablePlugins(NoPublishPlugin)
.settings(commonSettings)
.aggregate(coreJS, coreJVM)

lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("modules/core"))
.settings(commonSettings, releaseSettings, mimaSettings)
.settings(commonSettings)
.settings(
name := "cats-time"
)
Expand All @@ -22,20 +23,16 @@ lazy val coreJVM = core.jvm

lazy val docs = project
.in(file("modules/docs"))
.settings(commonSettings, micrositeSettings, skipOnPublishSettings)
.settings(commonSettings, micrositeSettings)
.dependsOn(coreJVM)
.disablePlugins(MimaPlugin)
.enablePlugins(MicrositesPlugin)
.enablePlugins(MdocPlugin)
.enablePlugins(NoPublishPlugin)
.settings(mdocIn := sourceDirectory.value / "main" / "mdoc")

lazy val contributors = Seq(
"ChristopherDavenport" -> "Christopher Davenport"
)

// General Settings
lazy val commonSettings = Seq(
organization := "io.chrisdavenport",
scalaVersion := "2.13.3",
crossScalaVersions := Seq(scalaVersion.value, "2.12.12"),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.0" cross CrossVersion.full),
Expand All @@ -47,72 +44,6 @@ lazy val commonSettings = Seq(
)
)

lazy val releaseSettings = {
import ReleaseTransformations._
Seq(
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
credentials ++= (
for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)
).toSeq,
publishArtifact in Test := false,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/ChristopherDavenport/cats-time"),
"[email protected]:ChristopherDavenport/cats-time.git"
)
),
homepage := Some(url("https://github.com/ChristopherDavenport/cats-time")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
pomIncludeRepository := { _ =>
false
},
pomExtra := {
<developers>
{
for ((username, name) <- contributors)
yield <developer>
<id>{username}</id>
<name>{name}</name>
<url>http://github.com/{username}</url>
</developer>
}
</developers>
}
)
}

lazy val micrositeSettings = Seq(
micrositeName := "cats-time",
micrositeDescription := "Cats Typeclasses for Java Time",
Expand Down Expand Up @@ -149,63 +80,27 @@ lazy val micrositeSettings = Seq(
micrositeGithubToken := sys.env.get("GITHUB_TOKEN")
)

lazy val mimaSettings = {
import sbtrelease.Version

def semverBinCompatVersions(major: Int, minor: Int, patch: Int): Set[(Int, Int, Int)] = {
val majorVersions: List[Int] = List(major)
val minorVersions: List[Int] =
if (major >= 1) Range(0, minor).inclusive.toList
else List(minor)
def patchVersions(currentMinVersion: Int): List[Int] =
if (minor == 0 && patch == 0) List.empty[Int]
else if (currentMinVersion != minor) List(0)
else Range(0, patch - 1).inclusive.toList

val versions = for {
maj <- majorVersions
min <- minorVersions
pat <- patchVersions(min)
} yield (maj, min, pat)
versions.toSet
}

def mimaVersions(version: String): Set[String] = {
Version(version) match {
case Some(Version(major, Seq(minor, patch), _)) =>
semverBinCompatVersions(major.toInt, minor.toInt, patch.toInt)
.map { case (maj, min, pat) => maj.toString + "." + min.toString + "." + pat.toString }
case _ =>
Set.empty[String]
}
}
// Safety Net For Exclusions
lazy val excludedVersions: Set[String] = Set("0.1.0")

// Safety Net for Inclusions
lazy val extraVersions: Set[String] = Set()

Seq(
mimaFailOnNoPrevious := false,
mimaFailOnProblem := mimaVersions(version.value).toList.headOption.isDefined,
mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions)
.filterNot(excludedVersions.contains(_))
.map { v =>
val moduleN = moduleName.value + "_" + scalaBinaryVersion.value.toString
organization.value % moduleN % v
},
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq()
}
// General Settings
inThisBuild(
List(
organization := "io.chrisdavenport",
developers := List(
Developer(
"ChristopherDavenport",
"Christopher Davenport",
"[email protected]",
url("https://github.com/ChristopherDavenport")
)
),
homepage := Some(url("https://github.com/ChristopherDavenport/cats-time")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomIncludeRepository := { _ => false },
scalacOptions in (Compile, doc) ++= Seq(
"-groups",
"-sourcepath",
(baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url",
"https://github.com/ChristopherDavenport/cats-time/blob/v" + version.value + "€{FILE_PATH}.scala"
)
)
}

lazy val skipOnPublishSettings = Seq(
skip in publish := true,
publish := (()),
publishLocal := (()),
publishArtifact := false,
publishTo := None
)
19 changes: 8 additions & 11 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.13")
addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.4")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.5")
addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.1.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.1.1")
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2")
addSbtPlugin("io.chrisdavenport" % "sbt-no-publish" % "0.1.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1")
addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.7")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")

0 comments on commit ddf854a

Please sign in to comment.