-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
172 lines (150 loc) · 4.29 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import com.github.sbt.git.SbtGit.GitKeys
import sbtcrossproject.{CrossProject, CrossType}
import org.typelevel.sbt.gha.JavaSpec.Distribution.Temurin
/// variables
val groupId = "eu.timepit"
val projectName = "status-page"
val gitHubOwner = "fthomas"
val Scala_2_12 = "2.12.20"
val Scala_2_13 = "2.13.15"
val Scala_3 = "3.6.2"
val moduleCrossPlatformMatrix = Map(
"cats" -> List(JVMPlatform),
"core" -> List(JVMPlatform)
)
/// sbt-github-actions configuration
ThisBuild / crossScalaVersions := Seq(Scala_2_12, Scala_2_13, Scala_3)
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches := Seq(
RefPredicate.Equals(Ref.Branch("master")),
RefPredicate.StartsWith(Ref.Tag("v"))
)
ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Run(
List("sbt ci-release"),
name = Some("Publish JARs"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec(Temurin, "8"))
ThisBuild / githubWorkflowBuild :=
Seq(
WorkflowStep.Sbt(List("validate"), name = Some("Build project")),
WorkflowStep.Use(UseRef.Public("codecov", "codecov-action", "v3"), name = Some("Codecov"))
)
ThisBuild / mergifyPrRules := {
val authorCondition = MergifyCondition.Or(
List(
MergifyCondition.Custom("author=scala-steward"),
MergifyCondition.Custom("author=scala-steward[bot]")
)
)
Seq(
MergifyPrRule(
"label scala-steward's PRs",
List(authorCondition),
List(MergifyAction.Label(List("dependency-update")))
),
MergifyPrRule(
"merge scala-steward's PRs",
List(authorCondition) ++ mergifySuccessConditions.value,
List(MergifyAction.Merge(Some("merge")))
)
)
}
/// projects
lazy val root = project
.in(file("."))
.aggregate(catsJVM)
.aggregate(coreJVM)
.settings(commonSettings)
.settings(noPublishSettings)
lazy val cats = myCrossProject("cats")
.dependsOn(core)
.settings(
libraryDependencies ++= Seq(
Dependencies.catsCore,
Dependencies.munit % Test
)
)
lazy val catsJVM = cats.jvm
lazy val core = myCrossProject("core")
.settings(
libraryDependencies ++= Seq(
Dependencies.munit % Test
)
)
lazy val coreJVM = core.jvm
/// settings
def myCrossProject(name: String): CrossProject =
CrossProject(name, file(name))(moduleCrossPlatformMatrix(name): _*)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform)
.in(file(s"modules/$name"))
.settings(moduleName := s"$projectName-$name")
.settings(commonSettings)
lazy val commonSettings = Def.settings(
compileSettings,
metadataSettings,
scaladocSettings
)
lazy val compileSettings = Def.settings(
scalaVersion := Scala_2_13,
crossScalaVersions := List(Scala_2_12, Scala_2_13, Scala_3)
)
lazy val metadataSettings = Def.settings(
name := projectName,
organization := groupId,
homepage := Some(url(s"https://github.com/$gitHubOwner/$projectName")),
startYear := Some(2018),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
headerLicense := Some(HeaderLicense.ALv2("2018", s"$projectName contributors")),
developers := List(
Developer(
id = "fthomas",
name = "Frank S. Thomas",
email = "",
url("https://github.com/fthomas")
)
)
)
lazy val noPublishSettings = Def.settings(
publish / skip := true
)
lazy val scaladocSettings = Def.settings(
Compile / doc / scalacOptions ++= {
val tree =
if (isSnapshot.value) GitKeys.gitHeadCommit.value
else GitKeys.gitDescribedVersion.value.map("v" + _)
Seq(
"-doc-source-url",
s"${scmInfo.value.get.browseUrl}/blob/${tree.get}€{FILE_PATH}.scala",
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath
)
}
)
/// commands
def addCommandsAlias(name: String, cmds: Seq[String]) =
addCommandAlias(name, cmds.mkString(";", ";", ""))
addCommandsAlias(
"validate",
Seq(
"clean",
"headerCheck",
"scalafmtCheck",
"scalafmtSbtCheck",
"test:scalafmtCheck",
"coverage",
"test",
"coverageReport",
"doc",
"package",
"packageSrc"
)
)