-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sbt
57 lines (50 loc) · 1.84 KB
/
release.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
import Utils._
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
import sbtrelease._
val sonatypeURL = "https://oss.sonatype.org/service/local/repositories/"
val updateReadme = { state: State =>
val extracted = Project.extract(state)
val scalaV = extracted get scalaBinaryVersion
val v = extracted get version
val org = extracted get organization
val n = (extracted get name).replace("-project", "")
val snapshotOrRelease = if (extracted get isSnapshot) "snapshots" else "releases"
val readme = "README.md"
val readmeFile = file(readme)
val newReadme = Predef
.augmentString(IO.read(readmeFile))
.lines
.map { line =>
val matchReleaseOrSnapshot = line.contains("SNAPSHOT") == v.contains("SNAPSHOT")
if (line.startsWith("libraryDependencies") && matchReleaseOrSnapshot) {
s"""libraryDependencies += "${org}" %% "${n}-core" % "$v""""
} else line
}
.mkString("", "\n", "\n")
IO.write(readmeFile, newReadme)
val git = new Git(extracted get baseDirectory)
git.add(readme) ! state.log.toScalaProcessLogger
git.commit("update " + readme, false) ! state.log.toScalaProcessLogger
git.cmd("diff", "HEAD^") ! state.log.toScalaProcessLogger
state
}
commands += Command.command("updateReadme")(updateReadme)
val updateReadmeProcess: ReleaseStep = updateReadme
releaseCrossBuild := true
releasePublishArtifactsAction := PgpKeys.publishSigned.value
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
// runTest,
setReleaseVersion,
commitReleaseVersion,
updateReadmeProcess,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
updateReadmeProcess,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)