1
+ import sbt ._
2
+ import Keys ._
3
+
4
+ import complete .DefaultParsers ._
5
+ import complete .Parser
6
+
7
+ object Release {
8
+
9
+ val versionNumberParser : Parser [String ] = {
10
+ val classifier : Parser [String ] = (" -" ~ ID ) map {
11
+ case (dash, id) => dash + id
12
+ }
13
+ val version : Parser [String ] = (Digit ~ chars(" .0123456789" ).* ~ classifier) map {
14
+ case ((first, rest), rest2) => ((first +: rest).mkString + rest2)
15
+ }
16
+ val complete = (chars(" v" ) ~ token(version, " <version number>" )) map {
17
+ case (v, num) => v + num
18
+ }
19
+ complete
20
+ }
21
+
22
+ def releaseParser (state : State ): Parser [String ] =
23
+ Space ~> versionNumberParser
24
+
25
+
26
+ val releaseHelp = Help (" release" ,
27
+ " release <git tag>" -> " Runs the release script for a given version number" ,
28
+ """ |release <git tag>
29
+ |
30
+ |Runs our release script. This will:
31
+ |1. Run all the tests (unit + scripted) for the current OS.
32
+ |2. Tag the git repo with the given tag (v<version>).
33
+ |3. Reload the build with the new version number from the git tag.
34
+ |4. publish all the artifacts to bintray.""" .stripMargin
35
+ )
36
+
37
+ def scriptedForPlatform : String = {
38
+ // TODO - Implement. Instead of only running tests we can, we should
39
+ // probably ping some service to see if all platform tests have
40
+ // succeeded.
41
+ " scripted universal/* debian/* rpm/*"
42
+ }
43
+
44
+ def releaseAction (state : State , tag : String ): State = {
45
+ // TODO - Ensure we're releasing on JDK 6, so we're binary compatible.
46
+ // First check to ensure we have a sane publishing environment...
47
+ " bintrayCheckCredentials" ::
48
+ " + test" ::
49
+ // Workaround for 0.12.4 scripted issue
50
+ " set scalaVersion in Global := \" 2.10.2\" " ::
51
+ scriptedForPlatform ::
52
+ // TODO - Signed tags, possibly using pgp keys?
53
+ (" git tag " + tag) ::
54
+ " reload" ::
55
+ // TODO - once we figure out bintray + pubishSigned, switch to signed
56
+ // releases.
57
+ " + publishSigned" ::
58
+ " bintrayPublishAllStaged" ::
59
+ (" git push origin " + tag) ::
60
+ state
61
+ }
62
+
63
+ val releaseCommand =
64
+ Command (" release" , releaseHelp)(releaseParser)(releaseAction)
65
+
66
+ def settings : Seq [Setting [_]]=
67
+ Seq (commands += releaseCommand)
68
+ }
0 commit comments