-
Notifications
You must be signed in to change notification settings - Fork 4
/
release.sbt
61 lines (54 loc) · 1.81 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
58
59
60
61
import sbtrelease._
import ReleaseStateTransformations._
import scala.sys.process._
val sonatypeURL = "https://oss.sonatype.org/service/local/repositories/"
val updateReadme: State => 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
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}" % "$v""""
}else line
}.mkString("", "\n", "\n")
IO.write(readmeFile, newReadme)
val git = new Git(extracted get baseDirectory)
git.add(readme) ! state.log
git.commit("update " + readme, sign = false, signOff = false) ! state.log
"git diff HEAD^" ! state.log
state
}
commands += Command.command("updateReadme")(updateReadme)
val updateReadmeProcess: ReleaseStep = updateReadme
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
updateReadmeProcess,
tagRelease,
ReleaseStep(
action = { state =>
val extracted = Project extract state
extracted.runAggregated(PgpKeys.publishSigned in Global in extracted.get(thisProjectRef), state)
},
enableCrossBuild = true
),
setNextVersion,
commitNextVersion,
updateReadmeProcess,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)
releaseCrossBuild := true
releaseTagName := {
"releases/" + (version in ThisBuild).value
}