Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to sbt-typelevel-ci-release #295

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
tags: [v*]

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand Down Expand Up @@ -59,23 +63,22 @@ 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 formatting
run: sbt ++${{ matrix.scala }} scalafmtCheckAll scalafmtSbtCheck
run: sbt '++${{ matrix.scala }}' scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Compile
run: sbt ++${{ matrix.scala }} Test/compile
- name: Test
run: sbt '++${{ matrix.scala }}' test

- name: Check binary compatibility
run: sbt ++${{ matrix.scala }} checkBinaryCompatibility
run: sbt '++${{ matrix.scala }}' mimaReportBinaryIssues

- name: Run tests on JVM
run: sbt ++${{ matrix.scala }} crossJVM/test
- name: Generate API documentation
run: sbt '++${{ matrix.scala }}' doc

- name: Run tests on JS
if: matrix.scala != '3.0.2'
run: sbt ++${{ matrix.scala }} crossJS/test
- name: Make target directories
run: mkdir -p target js/target jvm/target project/target

- name: Compress target directories
run: tar cf targets.tar target js/target jvm/target project/target
Expand All @@ -89,7 +92,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 Down Expand Up @@ -158,11 +161,16 @@ jobs:
tar xf targets.tar
rm targets.tar

- uses: olafurpg/setup-gpg@v3
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -d | gpg --import

- env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ++${{ matrix.scala }} ci-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
4 changes: 2 additions & 2 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ However, for new operations, simply providing a lazy by-name variant is often th

### Release Process

Mouse uses Github Actions, https://github.com/djspiewak/sbt-github-actions and https://github.com/olafurpg/sbt-ci-release for CI releases. Use the Github Create Release feature to tag a release, and it will publish to Sonatype automatically (using @benhutchison credentials).
Mouse uses Github Actions, https://github.com/djspiewak/sbt-github-actions and https://github.com/typelevel/sbt-typelevel for CI releases. Use the Github Create Release feature to tag a release, and it will publish to Sonatype automatically (using @benhutchison credentials).

sbt-release is no longer in use.
sbt-release and sbt-ci-release is no longer in use.
144 changes: 17 additions & 127 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,86 +1,33 @@
import sbt._
import sbtcrossproject.CrossPlugin.autoImport.crossProject

ThisBuild / githubWorkflowPublishTargetBranches := Seq()

val Scala212 = "2.12.15"
val Scala213 = "2.13.8"
val Scala3 = "3.0.2"

ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)

ThisBuild / organization := "org.typelevel"
ThisBuild / organizationName := "Typelevel"
ThisBuild / tlBaseVersion := "1.0"
ThisBuild / scalaVersion := Scala213

lazy val previousMouseVersion = "1.0.8"

def scalaVersionSpecificJVMFolder(srcName: String, srcBaseDir: java.io.File, scalaVersion: String) = {
def extraDir(suffix: String) = {
List(srcBaseDir / "jvm" / "src" / srcName / s"scala$suffix")
}

CrossVersion.partialVersion(scalaVersion) match {
case Some((2, _)) => extraDir("-2.x")
case Some((0 | 3, _)) => extraDir("-3.x")
case _ => Nil
}
}

def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scalaVersion: String) = {
def extraDirs(suffix: String) =
List(CrossType.Pure, CrossType.Full)
.flatMap(_.sharedSrcDir(srcBaseDir, srcName).toList.map(f => file(f.getPath + suffix)))

CrossVersion.partialVersion(scalaVersion) match {
case Some((2, _)) => extraDirs("-2.x")
case Some((0 | 3, _)) => extraDirs("-3.x")
case _ => Nil
}
}

// general settings
lazy val commonSettings = Seq(
name := "mouse",
organization := "org.typelevel",
sonatypeProfileName := "org.typelevel",
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(
"main",
baseDirectory.value,
scalaVersion.value
),
Test / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(
"test",
baseDirectory.value,
scalaVersion.value
),
mimaFailOnNoPrevious := false,
mimaPreviousArtifacts := Set(organization.value %% moduleName.value % previousMouseVersion)
)
ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / tlVersionIntroduced := Map("3" -> "1.0.3")
ThisBuild / tlCiReleaseBranches := Seq("main")

lazy val root = project
.in(file("."))
.aggregate(js, jvm)
.settings(
commonSettings,
publish / skip := true
)
.enablePlugins(NoPublishPlugin)

lazy val cross = crossProject(JSPlatform, JVMPlatform)
.in(file("."))
.settings(
commonSettings,
name := "mouse",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.7.0",
"org.scalameta" %%% "munit" % "0.7.29" % Test,
"org.scalameta" %%% "munit-scalacheck" % "0.7.29" % Test
),
licenses += ("MIT license", url("http://opensource.org/licenses/MIT")),
homepage := Some(url("https://github.com/typelevel/mouse")),
licenses := List("MIT license" -> url("http://opensource.org/licenses/MIT")),
developers := List(
Developer("benhutchison", "Ben Hutchison", "brhutchison@gmail.com", url = url("https://github.com/benhutchison"))
),
scmInfo := Some(
ScmInfo(url("https://github.com/typelevel/mouse"), "scm:git:https://github.com/typelevel/mouse.git")
),
scalacOptions ++= Seq("-feature", "-deprecation", "-language:implicitConversions", "-language:higherKinds"),
scalacOptions ++= {
scalaVersion.value match {
Expand All @@ -89,82 +36,25 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform)
case _ => Nil
}
},
Test / publishArtifact := false,
pomIncludeRepository := { _ => false }
)
.jvmSettings(
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificJVMFolder(
"main",
(Compile / baseDirectory).value.getParentFile(),
scalaVersion.value
),
Test / unmanagedSourceDirectories ++= scalaVersionSpecificJVMFolder(
"test",
(Test / baseDirectory).value.getParentFile(),
scalaVersion.value
)
mimaPreviousArtifacts ~= { _.filterNot(_.revision == "1.0.1") }
)
.jsSettings(
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2")),
publishConfiguration := publishConfiguration.value.withOverwrite(true),
mimaBinaryIssueFilters ++= {
danicheg marked this conversation as resolved.
Show resolved Hide resolved
import com.typesafe.tools.mima.core.ProblemFilters._
import com.typesafe.tools.mima.core._

Seq(
exclude[MissingClassProblem]("mouse.AllJvmSyntax"),
exclude[MissingClassProblem]("mouse.JvmStringOps"),
exclude[MissingClassProblem]("mouse.JvmStringOps$"),
exclude[MissingClassProblem]("mouse.StringJvmSyntax"),
exclude[MissingTypesProblem]("mouse.package$all$"),
exclude[MissingTypesProblem]("mouse.package$string$"),
exclude[DirectMissingMethodProblem]("mouse.package#all.stringJvmSyntaxMouse"),
exclude[DirectMissingMethodProblem]("mouse.package#string.stringJvmSyntaxMouse"),
exclude[DirectMissingMethodProblem]("mouse.package#string.stringJvmSyntaxMouse")
)
}
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2"))
)

val JDK8 = JavaSpec.temurin("8")
val JDK17 = JavaSpec.temurin("17")

ThisBuild / githubWorkflowJavaVersions := Seq(JDK8, JDK17)

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.StartsWith(Ref.Tag("v")))

ThisBuild / githubWorkflowPublishPreamble +=
WorkflowStep.Use(UseRef.Public("olafurpg", "setup-gpg", "v3"))

ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)

val NotScala3Cond = s"matrix.scala != '$Scala3'"

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep
ThisBuild / githubWorkflowBuild ~= { steps =>
val formatStep = WorkflowStep
.Sbt(
List("scalafmtCheckAll", "scalafmtSbtCheck"),
List("scalafmtCheckAll", "project /", "scalafmtSbtCheck"),
name = Some("Check formatting")
),
WorkflowStep.Sbt(List("Test/compile"), name = Some("Compile")),
WorkflowStep.Sbt(
List("checkBinaryCompatibility"),
name = Some("Check binary compatibility")
),
WorkflowStep.Sbt(List("crossJVM/test"), name = Some("Run tests on JVM")),
WorkflowStep.Sbt(List("crossJS/test"), name = Some("Run tests on JS"), cond = Some(NotScala3Cond))
)
)
formatStep +: steps
}

lazy val jvm = cross.jvm
lazy val js = cross.js
Expand Down
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.4.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")