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
|
package flow
import sbt._
import sbtrelease._
import sbtrelease.ReleasePlugin.autoImport._
import sbtrelease.ReleaseStateTransformations._
import ch.jodersky.sbt.jni.plugins.JniNative.autoImport._
import ch.jodersky.sbt.jni.plugins.JniPackage.autoImport._
import com.typesafe.sbt.pgp.PgpKeys._
object Release {
def settings: Seq[Setting[_]] = Seq(
//sign git tags
releaseVcs := Some(new SignedGit(Keys.baseDirectory.value)),
//publish signed
releasePublishArtifactsAction := publishSigned.value,
//build for multiple scala versions,
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
//Check that there are no snapshot dependencies
checkSnapshotDependencies,
//During a release, only native libraries in lib_native will be packaged
disableLocalBuild,
//Check that there are native libraries in lib_native and list all
//libraries that will be packaged
checkNativeLibs,
//Ask for release version and next development version
inquireVersions,
//Set version to release version and save
setReleaseVersion,
//Clean
runClean,
//Compile and test
runTest,
//If all tests pass, commit the updated version
commitReleaseVersion,
//Also create a tag
tagRelease,
//Publish artifacts, note that they will only be uploaded, not yet be released to the public
publishArtifacts,
//Bump version to next development
setNextVersion,
//TODO: update website
//Commit
commitNextVersion,
//Push all changes (commits and tags) to GitHub
pushChanges
)
)
/** Set `enableNativeCompilations` to false. */
lazy val disableLocalBuild = ReleaseStep(st => {
val st1 = ReleaseStateTransformations.reapply(Seq(
enableNativeCompilation in FlowBuild.native in Compile := false,
enableNativeCompilation in FlowBuild.native in Test := false
), st)
st1.log.info("Disabled compilation of native libraries during release process.")
st1
})
/** Release step that prints all native libraries that will be packaged
* and awaits approval from user. */
lazy val checkNativeLibs = ReleaseStep(action = st0 => {
val log = st0.log
val project = FlowBuild.native
val extracted = Project.extract(st0)
val (st1, libs) = extracted.runTask(unmanagedNativeLibraries in project in Compile, st0)
log.info("The following native libraries will be packaged:")
log.info("---------------------")
libs.toSeq.sortBy(_._2).foreach{ case (file, path) =>
log.info(path)
}
SimpleReader.readLine("Are the all native libraries listed (y/n)? [n] ") match {
case Some("y") => //do nothing
case _ => sys.error("Missing native libaries. Aborting release.")
}
st1
})
/** A Git wrapper that signs tags. */
class SignedGit(baseDir: File) extends Git(baseDir) {
override def tag(name: String, comment: String, force: Boolean = false) =
cmd("tag", "-s", name, "-m", comment, if(force) "-f" else "")
}
}
|