-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
161 lines (150 loc) · 5.93 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
import org.typelevel.sbt.gha.Permissions
import xerial.sbt.Sonatype.GitHubHosting
import xerial.sbt.Sonatype.sonatypeCentralHost
ThisBuild / tlBaseVersion := "0.1" // your current series x.y
ThisBuild / organization := "io.funktional"
ThisBuild / organizationName := "FunktionalIO"
ThisBuild / homepage := Some(url("https://github.com/FunktionalIO/rumpel"))
ThisBuild / startYear := Some(2024)
ThisBuild / licenses := Seq("EPL-2.0" -> url("https://www.eclipse.org/legal/epl-2.0/"))
ThisBuild / developers ++= List(
// your GitHub handle and name
tlGitHubDev("rlemaitre", "Raphaël Lemaitre")
)
ThisBuild / sonatypeProjectHosting := Some(GitHubHosting("FunktionalIO", "rumpel", "[email protected]"))
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/FunktionalIO/rumpel"), "scm:git:[email protected]:FunktionalIO/rumpel.git")
)
val Scala3 = "3.3.4"
ThisBuild / scalaVersion := Scala3 // the default Scala
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest")
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11"))
ThisBuild / tlCiHeaderCheck := true
ThisBuild / tlCiScalafmtCheck := true
ThisBuild / tlCiMimaBinaryIssueCheck := true
ThisBuild / tlCiDependencyGraphJob := true
ThisBuild / autoAPIMappings := true
val sharedSettings = Seq(
organization := "io.funktional",
name := "rumpel",
scalaVersion := "3.3.4",
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % "1.0.2" % Test
),
// Headers
headerMappings := headerMappings.value + (HeaderFileType.scala -> HeaderCommentStyle.cppStyleLineComment),
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2024-2024 by Raphaël Lemaitre and Contributors
|This software is licensed under the Eclipse Public License v2.0 (EPL-2.0).
|For more information see LICENSE or https://opensource.org/license/epl-2-0
|""".stripMargin
))
)
lazy val root =
project
.in(file("."))
.aggregate(rumpel.js, rumpel.jvm, rumpel.native, unidocs)
.settings(sharedSettings)
.settings(
publish / skip := true
)
lazy val rumpel =
crossProject(JSPlatform, JVMPlatform, NativePlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(sharedSettings)
.jvmSettings(
// Add JVM-specific settings here
).jsSettings(
// Add JS-specific settings here
scalaJSUseMainModuleInitializer := true
).nativeSettings(
// Add Native-specific settings here
)
lazy val unidocs = project
.in(file("unidocs"))
.enablePlugins(TypelevelUnidocPlugin)
.settings(
name := "rumpel-docs",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(rumpel.jvm)
)
.settings(sharedSettings)
// Github actions
val releasePreparation = WorkflowJob(
id = "prepare-release",
name = "👷 Prepare release",
oses = List("ubuntu-latest"),
cond = Some(
"""github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main'))"""
),
needs = List("build"),
env = Map("DTC_HEADLESS" -> "true"),
permissions = Some(Permissions.Specify.defaultPermissive),
steps = List(
WorkflowStep.CheckoutFull,
WorkflowStep.Run(
name = Some("Get previous tag"),
id = Some("previousTag"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
commands = List(
"""name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)""",
"""ref_name="${{ github.ref_name }}"""",
"""prefix="prepare-"""",
"""next_version=${ref_name/#$prefix}""",
"""echo "previousTag=$name"""",
"""echo "previousTag=$name" >> $GITHUB_ENV""",
"""echo "nextTag=$next_version"""",
"""echo "nextTag=$next_version" >> $GITHUB_ENV"""
)
),
WorkflowStep.Use(
name = Some("Update CHANGELOG"),
id = Some("changelog"),
ref = UseRef.Public("requarks", "changelog-action", "v1"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"token" -> "${{ github.token }}",
"fromTag" -> "${{ github.ref_name }}",
"toTag" -> "${{ env.previousTag }}",
"writeToFile" -> "true"
)
),
WorkflowStep.Use(
name = Some("Commit CHANGELOG.md"),
ref = UseRef.Public("stefanzweifel", "git-auto-commit-action", "v5"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"commit_message" -> "docs: update CHANGELOG.md for ${{ env.nextTag }} [skip ci]",
"branch" -> "main",
"file_pattern" -> "CHANGELOG.md docToolchainConfig.groovy"
)
),
WorkflowStep.Use(
name = Some("Create version tag"),
ref = UseRef.Public("rickstaa", "action-create-tag", "v1"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"tag" -> "${{ github.ref_name }}",
"message" -> "Release ${{ github.ref_name }}",
"force_push_tag" -> "true" // force push the tag to move it to HEAD
)
),
WorkflowStep.Use(
name = Some("Create release"),
ref = UseRef.Public("ncipollo", "release-action", "v1.14.0"),
cond = Some("""startsWith(github.ref, 'refs/tags/v')"""),
params = Map(
"allowUpdates" -> "true",
"draft" -> "false",
"makeLatest" -> "true",
"name" -> "${{ github.ref_name }}",
"tag" -> "${{ github.ref_name }}",
"body" -> "${{ steps.changelog.outputs.changes }}",
"token" -> "${{ github.token }}"
)
)
)
)
ThisBuild / githubWorkflowGeneratedCI ++= List(releasePreparation)
ThisBuild / githubWorkflowPublishNeeds := List("prepare-release")