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-ci-release #326

Merged
merged 7 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
68 changes: 29 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
push:
branches:
- master
- 're-releases-*'
- '*-pushbuild'

env:
JAVA_OPTS: -Xms6g -Xmx6g -XX:+UseG1GC
Expand All @@ -18,48 +16,40 @@ jobs:

strategy:
matrix:
scala: [3.3.1]
module: [sqltest, db, async, bigdata]
scala: [ 3.3.1 ]
module: [ sqltest, db, async, bigdata ]

steps:
- uses: actions/checkout@v4
- name: Setup Java and Scala
uses: actions/setup-java@v3.12.0
with:
distribution: temurin
java-version: '8'
check-latest: true

- name: Scala ${{ matrix.scala }} Building ${{ matrix.module }}
env:
SCALA_VERSION: ${{ matrix.scala }}
run: |
echo "SCALA_VERSION='$SCALA_VERSION'"
./build/build.sh ${{ matrix.module }}
- uses: actions/checkout@v4.0.0
- name: Setup Java and Scala
uses: actions/setup-java@v3.12.0
with:
distribution: temurin
java-version: '8'
check-latest: true

- name: Scala ${{ matrix.scala }} Building ${{ matrix.module }}
env:
SCALA_VERSION: ${{ matrix.scala }}
run: |
echo "SCALA_VERSION='$SCALA_VERSION'"
./build/build.sh ${{ matrix.module }}

release:
if: ${{github.event_name != 'pull_request'}}
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
scala: [3.3.1]
module: [base, db, async, bigdata, publish]

steps:
- uses: actions/checkout@v4
- name: Setup Java and Scala
uses: actions/setup-java@v3.12.0
with:
distribution: temurin
java-version: '8'
check-latest: true
- run: |
echo "PULL_REQUEST='$PULL_REQUEST'"
export BRANCH=$(git for-each-ref ${{ github.ref }} --format='%(refname:short)')
echo "BRANCH='$BRANCH'"
./build/release.sh ${{ matrix.module }}
env:
ENCRYPTION_PASSWORD: ${{ secrets.ENCRYPTION_PASSWORD }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PULL_REQUEST: ${{ !!github.event.pull_request }}
- uses: actions/checkout@v4.0.0
- name: Setup Java and Scala
uses: actions/setup-java@v3.12.0
with:
distribution: temurin
java-version: '8'
check-latest: true
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
147 changes: 34 additions & 113 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
import ReleaseTransformations._
//import com.typesafe.sbt.SbtScalariform.ScalariformKeys
//import scalariform.formatter.preferences._
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
import sbtrelease.ReleasePlugin
import scala.sys.process.Process
import java.io.{File => JFile}

ThisBuild / versionScheme := Some("always")
inThisBuild(
List(
organization := "io.getquill",
homepage := Some(url("https://zio.dev/zio-protoquill")),
licenses := List(("Apache License 2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))),
developers := List(
Developer("deusaquilus", "Alexander Ioffe", "", url("https://github.com/deusaquilus"))
),
scmInfo := Some(
ScmInfo(url("https://github.com/zio/zio-protoquill"), "git:git@github.com:zio/zio-protoquill.git")
),
versionScheme := Some("always"),
)
)

addCommandAlias("runCommunityBuild", "; quill-sql/test; quill-sql-tests/test; quill-cassandra/Test/compile")
addCommandAlias("fmt", "all scalafmt test:scalafmt")

// During release cycles, GPG will expect passphrase user-input EVEN when --passphrase is specified
// this should add --pinentry-loopback in order to disable that. See here for more info:
// https://github.com/sbt/sbt-pgp/issues/178
Global / useGpgPinentry := true

releaseVersion := { ver =>
println(s"=== Releasing on initially specified version: ${ver}")
ver
}
releaseNextVersion := { ver =>
val withoutLast = ver.reverse.dropWhile(_.isDigit).reverse
val last = ver.reverse.takeWhile(_.isDigit).reverse
println(s"=== Detected original version: ${ver}. Which is ${withoutLast} + ${last}")
// see if the last group of chars are numeric, if they are, just increment
val actualLast = scala.util.Try(last.toInt).map(i => (i + 1).toString).getOrElse(last)
val newVer = withoutLast + actualLast + "-SNAPSHOT"
println(s"=== Final computed version is: ${newVer}")
newVer
}

val isCommunityBuild =
sys.props.getOrElse("community", "false").toBoolean

Expand Down Expand Up @@ -103,27 +90,21 @@ val filteredModules = {
selectedModules
}

lazy val `quill` = {
lazy val `quill` =
(project in file("."))
.settings(commonSettings: _*)
// Unless release settings bubbled up here, they won't actually be used for the project
// release. E.g. if you don't want to run tests on a release (i.e. if they were run on a previous step)
// and release-settings here are not included tests will still be run etc...
.settings(releaseSettings: _*)
.aggregate(filteredModules.map(_.project): _*)
.dependsOn(filteredModules: _*)
.settings(
publishArtifact := false,
publish / skip := true,
publishLocal / skip := true,
publishSigned / skip := true,
crossScalaVersions := Nil, // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully
)
}
.aggregate(filteredModules.map(_.project): _*)

lazy val `quill-sql` =
(project in file("quill-sql"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
resolvers ++= Seq(
Resolver.mavenLocal,
Expand Down Expand Up @@ -158,9 +139,10 @@ lazy val `quill-sql` =
// Moving heavy tests to separate module so it can be compiled in parallel with others
lazy val `quill-sql-tests` =
(project in file("quill-sql-tests"))
.settings(publish / skip := true)
.settings(commonSettings: _*)
.settings(
Test / testOptions += Tests.Argument("-oF")
Test / testOptions += Tests.Argument("-oF")
)
.dependsOn(`quill-sql` % "compile->compile;test->test")

Expand All @@ -169,15 +151,13 @@ lazy val `quill-sql-tests` =
lazy val `quill-jdbc` =
(project in file("quill-jdbc"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(jdbcTestingSettings: _*)
.dependsOn(`quill-sql` % "compile->compile;test->test")

ThisBuild / libraryDependencySchemes += "org.typelevel" %% "cats-effect" % "always"
lazy val `quill-doobie` =
(project in file("quill-doobie"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(jdbcTestingSettings: _*)
.settings(
libraryDependencies ++= Seq(
Expand All @@ -190,7 +170,6 @@ lazy val `quill-doobie` =
lazy val `quill-jasync` =
(project in file("quill-jasync"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
Expand All @@ -202,7 +181,6 @@ lazy val `quill-jasync` =
lazy val `quill-jasync-postgres` =
(project in file("quill-jasync-postgres"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
Expand All @@ -214,28 +192,26 @@ lazy val `quill-jasync-postgres` =
lazy val `quill-caliban` =
(project in file("quill-caliban"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.ghostdogpr" %% "caliban" % "2.0.2",
"com.github.ghostdogpr" %% "caliban-zio-http" % "2.0.2",
"com.github.ghostdogpr" %% "caliban-zio-http" % "2.0.2",
// Adding this to main dependencies would force users to use logback-classic for SLF4j unless the specifically remove it
// seems to be safer to just exclude & add a commented about need for a SLF4j implementation in Docs.
"ch.qos.logback" % "logback-classic" % "1.2.12" % Test,
"io.d11" %% "zhttp" % "2.0.0-RC11" % Test,
"io.d11" %% "zhttp" % "2.0.0-RC11" % Test,
// Don't want to make this dependant on zio-test for the testing code so importing this here separately
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalatest" %% "scalatest-mustmatchers" % scalatestVersion % Test,
"org.postgresql" % "postgresql" % "42.2.27" % Test,
"org.postgresql" % "postgresql" % "42.2.27" % Test,
)
)
.dependsOn(`quill-jdbc-zio` % "compile->compile")

lazy val `quill-zio` =
(project in file("quill-zio"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
Expand All @@ -248,17 +224,16 @@ lazy val `quill-zio` =
lazy val `quill-jdbc-zio` =
(project in file("quill-jdbc-zio"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(jdbcTestingLibraries: _*)
.settings(
libraryDependencies ++= Seq(
// Needed for PGObject in JsonExtensions but not necessary if user is not using postgres
"org.postgresql" % "postgresql" % "42.6.0" % "provided",
"org.postgresql" % "postgresql" % "42.6.0" % "provided",
"dev.zio" %% "zio-json" % "0.6.2"
),
Test / runMain / fork := true,
Test / fork := true,
Test / testGrouping := {
Test / runMain / fork := true,
Test / fork := true,
Test / testGrouping := {
(Test / definedTests).value map { test =>
if (test.name endsWith "IntegrationSpec")
Tests.Group(name = test.name, tests = Seq(test), runPolicy = Tests.SubProcess(
Expand All @@ -276,7 +251,6 @@ lazy val `quill-jdbc-zio` =
lazy val `quill-cassandra` =
(project in file("quill-cassandra"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := false,
libraryDependencies ++= Seq(
Expand All @@ -288,7 +262,6 @@ lazy val `quill-cassandra` =
lazy val `quill-cassandra-zio` =
(project in file("quill-cassandra-zio"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
Expand All @@ -305,8 +278,7 @@ val includeFormatter =
sys.props.getOrElse("formatScala", "false").toBoolean

lazy val commonSettings =
basicSettings ++
{
basicSettings ++ {
if (isCommunityRemoteBuild)
Seq(
Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
Expand All @@ -318,16 +290,16 @@ lazy val commonSettings =
lazy val jdbcTestingLibraries = Seq(
// JDBC Libraries for testing of quill-jdbc___ contexts
libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "4.0.3" exclude("org.slf4j", "*"),
"com.zaxxer" % "HikariCP" % "4.0.3" exclude("org.slf4j", "*"),
// In 8.0.22 error happens: Conversion from java.time.OffsetDateTime to TIMESTAMP is not supported
"com.mysql" % "mysql-connector-j" % "8.1.0" % Test,
"com.h2database" % "h2" % "2.2.222" % Test,
"com.mysql" % "mysql-connector-j" % "8.1.0" % Test,
"com.h2database" % "h2" % "2.2.222" % Test,
// In 42.2.18 error happens: PSQLException: conversion to class java.time.OffsetTime from timetz not supported
"org.postgresql" % "postgresql" % "42.6.0" % Test,
"org.xerial" % "sqlite-jdbc" % "3.42.0.1" % Test,
"org.postgresql" % "postgresql" % "42.6.0" % Test,
"org.xerial" % "sqlite-jdbc" % "3.42.0.1" % Test,
// In 7.1.1-jre8-preview error happens: The conversion to class java.time.OffsetDateTime is unsupported.
"com.microsoft.sqlserver" % "mssql-jdbc" % "7.2.2.jre8" % Test,
"com.oracle.ojdbc" % "ojdbc8" % "19.3.0.0" % Test,
"com.microsoft.sqlserver" % "mssql-jdbc" % "7.2.2.jre8" % Test,
"com.oracle.ojdbc" % "ojdbc8" % "19.3.0.0" % Test,
//"org.mockito" %% "mockito-scala-scalatest" % "1.16.2" % Test
)
)
Expand All @@ -345,7 +317,6 @@ lazy val basicSettings = Seq(
ExclusionRule("org.scala-lang.modules", "scala-collection-compat_2.13")
),
scalaVersion := "3.3.1",
organization := "io.getquill",
// The -e option is the 'error' report of ScalaTest. We want it to only make a log
// of the failed tests once all tests are done, the regular -o log shows everything else.
// Test / testOptions ++= Seq(
Expand All @@ -358,53 +329,3 @@ lazy val basicSettings = Seq(
"-language:implicitConversions", "-explain"
)
)

lazy val releaseSettings = ReleasePlugin.extraReleaseCommands ++ Seq(
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishMavenStyle := true,
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")
},
pgpSecretRing := file("local.secring.gpg"),
pgpPublicRing := file("local.pubring.gpg"),
releaseVersionBump := sbtrelease.Version.Bump.Next,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := {
Seq[ReleaseStep]() ++
doOnDefault(checkSnapshotDependencies) ++
doOnDefault(inquireVersions) ++
doOnDefault(runClean) ++
doOnPush (setReleaseVersion) ++
doOnPush (commitReleaseVersion) ++
doOnPush (tagRelease) ++
doOnDefault(publishArtifacts) ++
doOnPush (setNextVersion) ++
doOnPush (commitNextVersion) ++
//doOnPush(releaseStepCommand("sonatypeReleaseAll")) ++
doOnPush (pushChanges)
},
homepage := Some(url("http://github.com/getquill/protoquill")),
licenses := List(("Apache License 2.0", url("https://raw.githubusercontent.com/getquill/protoquill/master/LICENSE.txt"))),
developers := List(
Developer("deusaquilus", "Alexander Ioffe", "", url("https://github.com/deusaquilus"))
),
scmInfo := Some(
ScmInfo(url("https://github.com/getquill/protoquill"), "git:git@github.com:getquill/protoquill.git")
)
)

def doOnDefault(steps: ReleaseStep*): Seq[ReleaseStep] =
Seq[ReleaseStep](steps: _*)

def doOnPush(steps: ReleaseStep*): Seq[ReleaseStep] =
if (skipPush)
Seq[ReleaseStep]()
else
Seq[ReleaseStep](steps: _*)

val skipPush =
sys.props.getOrElse("skipPush", "false").toBoolean
Binary file removed build/credentials.sbt.enc
Binary file not shown.
Binary file removed build/deploy_key.pem.enc
Binary file not shown.
Binary file removed build/pubring.gpg.enc
Binary file not shown.
Loading