Skip to content

Commit a72c646

Browse files
committed
build: Modernize, use sbt-ci-release for releases
1 parent d279841 commit a72c646

File tree

4 files changed

+49
-96
lines changed

4 files changed

+49
-96
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
on:
3+
push:
4+
tags: ["v*"]
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
if: github.repository == 'lightbend/config'
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Setup JDK
13+
uses: actions/setup-java@v2
14+
with:
15+
distribution: temurin
16+
java-version: 11
17+
- env:
18+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
19+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
20+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
21+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
22+
run: sbt ci-release

build.sbt

Lines changed: 25 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// to release, bump major/minor/micro as appropriate,
2-
// update NEWS, update version in README.md, tag, then
3-
// publishSigned.
4-
// Release tags should follow: http://semver.org/
5-
import scalariform.formatter.preferences._
6-
71
ThisBuild / git.baseVersion := "1.4.0"
82
ThisBuild / organization := "com.typesafe"
93
ThisBuild / Compile / scalacOptions := List("-unchecked", "-deprecation", "-feature")
@@ -40,49 +34,39 @@ lazy val root = (project in file("."))
4034
simpleLibJava, simpleAppJava, complexAppJava
4135
)
4236
.settings(commonSettings)
43-
.settings(nocomma {
44-
name := "config-root"
45-
git.baseVersion := (ThisBuild / git.baseVersion).value
46-
doc / aggregate := false
47-
doc := (configLib / Compile / doc).value
48-
packageDoc / aggregate := false
37+
.settings(
38+
name := "config-root",
39+
git.baseVersion := (ThisBuild / git.baseVersion).value,
40+
doc / aggregate := false,
41+
doc := (configLib / Compile / doc).value,
42+
packageDoc / aggregate := false,
4943
packageDoc := (configLib / Compile / packageDoc).value
50-
checkstyle / aggregate := false
51-
checkstyle := (configLib / Compile / checkstyle).value
52-
useGpg := true
53-
PgpKeys.publishSigned / aggregate := false
54-
PgpKeys.publishSigned := (PgpKeys.publishSigned in configLib).value
55-
PgpKeys.publishLocalSigned / aggregate := false
56-
PgpKeys.publishLocalSigned := (PgpKeys.publishLocalSigned in configLib).value
57-
})
44+
)
5845

5946
lazy val configLib = Project("config", file("config"))
6047
.enablePlugins(SbtOsgi)
6148
.dependsOn(testLib % "test->test")
6249
.settings(osgiSettings)
63-
.settings(nocomma {
64-
autoScalaLibrary := false
65-
crossPaths := false
66-
libraryDependencies += "net.liftweb" %% "lift-json" % "3.3.0" % Test
67-
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
50+
.settings(
51+
autoScalaLibrary := false,
52+
crossPaths := false,
53+
libraryDependencies += "net.liftweb" %% "lift-json" % "3.3.0" % Test,
54+
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test,
6855

6956
Compile / compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8",
70-
"-g", "-Xlint:unchecked")
57+
"-g", "-Xlint:unchecked"),
7158

7259
Compile / doc / javacOptions ++= Seq("-group", s"Public API (version ${version.value})", "com.typesafe.config:com.typesafe.config.parser",
73-
"-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl")
74-
javadocSourceBaseUrl := {
75-
for (gitHead <- com.typesafe.sbt.SbtGit.GitKeys.gitHeadCommit.value)
76-
yield s"https://github.com/lightbend/config/blob/$gitHead/config/src/main/java"
77-
}
60+
"-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl"),
61+
javadocSourceBaseUrl := Some("https://github.com/lightbend/config/tree/main/config/src/main/java"),
7862
// because we test some global state such as singleton caches,
7963
// we have to run tests in serial.
80-
Test / parallelExecution := false
64+
Test / parallelExecution := false,
8165

82-
test / fork := true
83-
Test / fork := true
84-
run / fork := true
85-
Test/ run / fork := true
66+
test / fork := true,
67+
Test / fork := true,
68+
run / fork := true,
69+
Test/ run / fork := true,
8670

8771
//env vars for tests
8872
Test / envVars ++= Map("testList.0" -> "0",
@@ -99,63 +83,17 @@ lazy val configLib = Project("config", file("config"))
9983
"SECRET_A" -> "A", // ConfigTest.renderShowEnvVariableValues
10084
"SECRET_B" -> "B", // ConfigTest.renderShowEnvVariableValues
10185
"SECRET_C" -> "C" // ConfigTest.renderShowEnvVariableValues
102-
)
86+
),
10387

104-
OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl")
105-
publish := sys.error("use publishSigned instead of plain publish")
106-
publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal")
88+
OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl"),
89+
publish := sys.error("use publishSigned instead of plain publish"),
90+
publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal"),
10791
Compile / packageBin / packageOptions +=
10892
Package.ManifestAttributes("Automatic-Module-Name" -> "typesafe.config" )
109-
scalariformPreferences := scalariformPreferences.value
110-
.setPreference(IndentSpaces, 4)
111-
.setPreference(FirstArgumentOnNewline, Preserve)
112-
113-
checkstyleConfigLocation := CheckstyleConfigLocation.File((baseDirectory.value / "checkstyle-config.xml").toString)
114-
115-
Compile / checkstyle := {
116-
val log = streams.value.log
117-
(Compile / checkstyle).value
118-
val resultFile = (Compile / checkstyleOutputFile).value
119-
val results = scala.xml.XML.loadFile(resultFile)
120-
val errorFiles = results \\ "checkstyle" \\ "file"
121-
122-
def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = {
123-
val line: String = (node \ "@line" text)
124-
val msg: String = (node \ "@message" text)
125-
val source: String = (node \ "@source" text)
126-
(line, msg, source)
127-
}
128-
def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = {
129-
val name: String = (fileNode \ "@name" text)
130-
val errors = (fileNode \\ "error") map { e => errorFromXml(e) }
131-
errors map { case (line, error, source) => (name, line, error, source) }
132-
}
133-
134-
val errors = errorFiles flatMap { f => errorsFromXml(f) }
135-
136-
if (errors.nonEmpty) {
137-
for (e <- errors) {
138-
log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})")
139-
}
140-
throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors")
141-
}
142-
log.info("No errors from checkstyle")
143-
}
144-
145-
// add checkstyle as a dependency of doc
146-
Compile / doc := ((Compile / doc).dependsOn(Compile / checkstyle)).value
147-
148-
findbugsReportType := Some(FindbugsReport.Html)
149-
findbugsReportPath := Some(crossTarget.value / "findbugs.html")
150-
findbugsEffort := FindbugsEffort.Maximum
151-
findbugsMaxMemory := 2000
152-
})
93+
)
15394

15495
lazy val commonSettings: Seq[Setting[_]] = Def.settings(
15596
unpublished,
156-
scalariformPreferences := scalariformPreferences.value
157-
.setPreference(IndentSpaces, 4)
158-
.setPreference(FirstArgumentOnNewline, Preserve),
15997
Compile / compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
16098
)
16199

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.8
1+
sbt.version=1.11.2

project/plugins.sbt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
addSbtPlugin("com.github.sbt" % "sbt-findbugs" % "2.0.0")
2-
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.1.0")
3-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0-M2")
41
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.3")
5-
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
62

7-
addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "3.1.1")
8-
9-
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
10-
addSbtPlugin("com.eed3si9n" % "sbt-nocomma" % "0.1.0")
3+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.3")

0 commit comments

Comments
 (0)