From 8bf3ca1e1cc9744bd38dc97fd6eaf6d705f3ea67 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 6 Feb 2022 08:45:49 -0800 Subject: [PATCH] Migrate to sbt-typelevel-ci-release (#429) * Migrate to sbt-typelevel-ci-release * Rescope publish settings * Set tlVersionIntroduced * Poke ci * Update to latest sbt-typelevel --- .github/workflows/ci.yml | 127 +++++++++++++++++++++++++++++++++++---- .sbtrc | 2 +- build.sbt | 87 ++++++++------------------- project/plugins.sbt | 4 +- 4 files changed, 143 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c65e7cd..982fe5b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -25,7 +29,7 @@ jobs: os: [ubuntu-latest] scala: [2.12.15, 2.13.8] java: [temurin@8] - ci: [validateJVM, validateJS, validateNative] + project: [rootJS, rootJVM, rootNative] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -53,15 +57,49 @@ 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 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck - - name: Validation - run: sbt ++${{ matrix.scala }} '${{ matrix.ci }}' + - name: Check formatting + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' scalafmtCheckAll scalafmtSbtCheck + + - name: fastOptJS + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/fastOptJS + + - name: nativeLink + if: matrix.project == 'rootNative' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink + + - name: Test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test + + - name: Check binary compatibility + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues + + - name: Generate API documentation + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc + + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: mkdir -p target .js/target core/.native/target core/.js/target core/.jvm/target .jvm/target .native/target project/target + + - name: Compress target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: tar cf targets.tar target .js/target core/.native/target core/.js/target core/.jvm/target .jvm/target .native/target project/target + + - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} + path: targets.tar 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] @@ -93,11 +131,76 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - uses: olafurpg/setup-gpg@v3 + - name: Download target directories (2.12.15, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS + + - name: Inflate target directories (2.12.15, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM + + - name: Inflate target directories (2.12.15, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootNative + + - name: Inflate target directories (2.12.15, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS + + - name: Inflate target directories (2.13.8, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM + + - name: Inflate target directories (2.13.8, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative + + - name: Inflate target directories (2.13.8, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' + run: echo $PGP_SECRET | base64 -d | gpg --import + + - 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) - - 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: Publish + run: sbt '++${{ matrix.scala }}' tlRelease diff --git a/.sbtrc b/.sbtrc index 741a9b6e..39ec4794 100644 --- a/.sbtrc +++ b/.sbtrc @@ -1 +1 @@ -alias boot = ;reload ;project kittens ;iflast shell +alias boot = ;reload ;project / ;iflast shell diff --git a/build.sbt b/build.sbt index 34a37f42..2d9af0d1 100644 --- a/build.sbt +++ b/build.sbt @@ -2,10 +2,8 @@ import sbt._ ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.8") ThisBuild / scalaVersion := "2.13.8" - -lazy val buildSettings = Seq( - organization := "org.typelevel" -) +ThisBuild / tlBaseVersion := "2.3" +ThisBuild / organization := "org.typelevel" val catsVersion = "2.7.0" val disciplineMunitVersion = "1.0.9" @@ -36,43 +34,34 @@ lazy val commonSettings = Seq( "org.typelevel" %%% "alleycats-core" % catsVersion, "com.chuusai" %%% "shapeless" % shapelessVersion, "org.typelevel" %%% "cats-testkit" % catsVersion % Test, + "org.scalameta" %%% "munit" % "0.7.29" % Test, "org.typelevel" %%% "discipline-munit" % disciplineMunitVersion % Test, "org.scala-lang" % "scala-reflect" % scalaVersion.value % Test, compilerPlugin(("org.typelevel" %% "kind-projector" % kindProjectorVersion).cross(CrossVersion.full)) ), - Test / parallelExecution := false, - versionScheme := Some("semver-spec"), - mimaPreviousArtifacts := Set(organization.value %% moduleName.value % "2.2.1") + Test / parallelExecution := false ) console / initialCommands := """import shapeless._, cats._, cats.derived._""" -lazy val commonJsSettings = Seq( - Global / scalaJSStage := FastOptStage, - Test / scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)) -) - -lazy val coreSettings = - Seq.concat(buildSettings, commonSettings, crossVersionSharedSources, publishSettings) - -lazy val kittens = project - .in(file(".")) - .aggregate(coreJS, coreJVM, coreNative) - .dependsOn(coreJS, coreJVM, coreNative) - .settings(coreSettings: _*) - .settings(noPublishSettings) +lazy val root = tlCrossRootProject.aggregate(core) lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform) .crossType(CrossType.Pure) .settings(moduleName := "kittens") - .settings(coreSettings: _*) - .jsSettings(commonJsSettings: _*) + .settings(commonSettings: _*) + .jsSettings( + tlVersionIntroduced := List("2.12", "2.13").map(_ -> "2.1.0").toMap + ) + .nativeSettings( + tlVersionIntroduced := List("2.12", "2.13").map(_ -> "2.2.2").toMap + ) lazy val coreJVM = core.jvm lazy val coreJS = core.js lazy val coreNative = core.native -addCommandAlias("root", ";project kittens") +addCommandAlias("root", ";project /") addCommandAlias("jvm", ";project coreJVM") addCommandAlias("js", ";project coreJS") addCommandAlias("native", ";project coreNative") @@ -87,43 +76,19 @@ addCommandAlias("mima", "coreJVM/mimaReportBinaryIssues") addCommandAlias("fmt", "all scalafmtSbt scalafmtAll") addCommandAlias("fmtCheck", "all scalafmtSbtCheck scalafmtCheckAll") -lazy val crossVersionSharedSources: Seq[Setting[_]] = Seq(Compile, Test).map { sc => - (sc / unmanagedSourceDirectories) ++= (sc / unmanagedSourceDirectories).value.map { dir: File => - new File(dir.getPath + "_" + scalaBinaryVersion.value) - } -} - -lazy val publishSettings = Seq( - Test / publishArtifact := false, - pomIncludeRepository := (_ => false), - homepage := Some(url("https://github.com/typelevel/kittens")), - licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")), - scmInfo := Some(ScmInfo(url("https://github.com/typelevel/kittens"), "scm:git:git@github.com:typelevel/kittens.git")), - developers := List( - Developer("milessabin", "Miles Sabin", "", url("http://milessabin.com/blog")), - Developer("kailuowang", "Kai(luo) Wang", "kailuo.wang@gmail.com", url("http://kailuowang.com/")), - Developer("joroKr21", "Georgi Krastev", "joro.kr.21@gmail.com", url("https://twitter.com/Joro_Kr")) - ) +ThisBuild / licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")) +ThisBuild / developers := List( + Developer("milessabin", "Miles Sabin", "", url("http://milessabin.com/blog")), + Developer("kailuowang", "Kai(luo) Wang", "kailuo.wang@gmail.com", url("http://kailuowang.com/")), + Developer("joroKr21", "Georgi Krastev", "joro.kr.21@gmail.com", url("https://twitter.com/Joro_Kr")) ) -lazy val noPublishSettings = - publish / skip := true - -ThisBuild / githubWorkflowJavaVersions := List(JavaSpec.temurin("8")) -ThisBuild / githubWorkflowArtifactUpload := false -ThisBuild / githubWorkflowBuildMatrixAdditions += "ci" -> List("validateJVM", "validateJS", "validateNative") -ThisBuild / githubWorkflowBuild := List(WorkflowStep.Sbt(List("${{ matrix.ci }}"), name = Some("Validation"))) -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 }}" +ThisBuild / tlCiReleaseBranches := Seq("main") +ThisBuild / githubWorkflowBuild ~= { steps => + val formatStep = WorkflowStep + .Sbt( + List("scalafmtCheckAll", "scalafmtSbtCheck"), + name = Some("Check formatting") ) - ) -) + formatStep +: steps +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 84061d83..93ad1a99 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,5 @@ addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0") -addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1") +addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.4.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")