This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathpublish.sbt
85 lines (69 loc) · 2.77 KB
/
publish.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import scala.sys.process._
lazy val scaladoc =
taskKey[Unit]("Rebuilds the Scaladoc and pushes the updated Scaladoc to GitHub pages without committing to the git repository")
scaladoc := {
println("Creating Scaladoc")
doc.in(Test).value
println("Uploading Scaladoc to GitHub Pages")
ghpagesPushSite.value
}
/** Best practice is to comment your commits before invoking this task: `git commit -am "Your comment here"`.
* This task does the following:
* 1. `git pull` when it starts.
* 2. Attempts to build Scaladoc, which fails if there is a compile error
* 3. Ensures any uncommitted changes are committed before publishing, including new files; it provides the comment as "-".
* 4. Git pushes all files
* 5. Uploads new Scaladoc
* 6. Publishes new version to Bintray */
lazy val commitAndDoc =
taskKey[Unit]("Rebuilds the docs, commits the git repository, and publishes the updated Scaladoc without publishing a new version")
commitAndDoc := {
try {
println("Fetching latest updates for this git repo")
"git pull".!!
println("Creating Scaladoc")
doc.in(Test).value
val changedFileNames: String = "git diff --name-only".!!.trim.replace("\n", ", ")
if (changedFileNames.nonEmpty) {
println(s"About to commit these changed files: $changedFileNames")
"git add -A".!!
"git commit -m -".!!
}
/*val stagedFileNames = "git diff --cached --name-only".!!.trim.replace("\n", ", ")
if (stagedFileNames.nonEmpty) {
println(s"About to push these staged files: $stagedFileNames")
}*/
println("About to git push to origin")
"git push origin HEAD".!! // See https://stackoverflow.com/a/20922141/553865
println("Uploading Scaladoc to GitHub Pages")
ghpagesPushSite.value
} catch {
case e: Exception => println(e.getMessage)
}
()
}
/** Publish a new version of this library to BinTray.
* Be sure to update the version string in build.sbt before running this task. */
lazy val publishAndTag =
taskKey[Unit]("Invokes commitAndPublish, then creates a git tag for the version string defined in build.sbt")
publishAndTag := {
commitAndDoc.in(Compile).value
publish.value
println(s"Creating git tag for v${ version.value }")
s"""git tag -a ${ version.value } -m ${ version.value }""".!!
s"""git push origin --tags""".!!
()
}
// See http://www.scala-sbt.org/1.0/docs/Howto-Scaladoc.html
autoAPIMappings := true
apiURL := Some(url("https://mslinn.github.io/web3j-scala/latest/api"))
bintrayOrganization := Some("micronautics")
bintrayRepository := "scala"
bintrayPackage := "web3j-scala"
// sbt-site settings
enablePlugins(SiteScaladocPlugin)
siteSourceDirectory := target.value / "api"
publishSite
// sbt-ghpages settings
enablePlugins(GhpagesPlugin)
git.remoteRepo := s"git@github.com:mslinn/${ name.value }.git"