-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding relese script and bintray publishing
- Loading branch information
Showing
8 changed files
with
146 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pgpSecretRing := baseDirectory.value / "secring.pgp" | ||
|
||
pgpPublicRing := baseDirectory.value / "pubring.pgp" | ||
|
||
pgpReadOnly := false | ||
|
||
pgpPassphrase := Some("test password".toCharArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % sys.props("project.version")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
> pgp-cmd gen-key | ||
|
||
$ exists secring.pgp | ||
$ exists pubring.pgp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
import complete.DefaultParsers._ | ||
import complete.Parser | ||
|
||
object Release { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
val versionNumberParser: Parser[String] = { | ||
val classifier: Parser[String] = ("-" ~ ID) map { | ||
case (dash, id) => dash + id | ||
} | ||
val version: Parser[String] = (Digit ~ chars(".0123456789").* ~ classifier) map { | ||
case ((first, rest), rest2) => ((first +: rest).mkString + rest2) | ||
} | ||
val complete = (chars("v") ~ token(version, "<version number>")) map { | ||
case (v, num) => v + num | ||
} | ||
complete | ||
} | ||
|
||
def releaseParser(state: State): Parser[String] = | ||
Space ~> versionNumberParser | ||
|
||
|
||
val releaseHelp = Help("release", | ||
"release <git tag>" -> "Runs the release script for a given version number", | ||
"""|release <git tag> | ||
| | ||
|Runs our release script. This will: | ||
|1. Run all the tests (unit + scripted) for the current OS. | ||
|2. Tag the git repo with the given tag (v<version>). | ||
|3. Reload the build with the new version number from the git tag. | ||
|4. publish all the artifacts to bintray.""".stripMargin | ||
) | ||
|
||
def scriptedForPlatform: String = { | ||
// TODO - Implement. Instead of only running tests we can, we should | ||
// probably ping some service to see if all platform tests have | ||
// succeeded. | ||
"scripted universal/* debian/* rpm/*" | ||
} | ||
|
||
def releaseAction(state: State, tag: String): State = { | ||
// TODO - Ensure we're releasing on JDK 6, so we're binary compatible. | ||
// First check to ensure we have a sane publishing environment... | ||
"bintrayCheckCredentials" :: | ||
"all test scripted" :: | ||
// TODO - Signed tags, possibly using pgp keys? | ||
("git tag " + tag) :: | ||
"reload" :: | ||
"all library/publishSigned plugin/publishSigned" :: | ||
"bintrayPublishAllStaged" :: | ||
("git push origin " + tag) :: | ||
state | ||
} | ||
|
||
val releaseCommand = | ||
Command("release", releaseHelp)(releaseParser)(releaseAction) | ||
|
||
def settings: Seq[Setting[_]]= | ||
Seq(commands += releaseCommand) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import sbt._ | ||
import sbt.Keys._ | ||
|
||
object Bintray { | ||
val bintrayPublishAllStaged = taskKey[Unit]("Publish all staged artifacts on bintray.") | ||
val checkBintrayCredentials = taskKey[Unit]("Checks to see if bintray credentials are configured.") | ||
val bintrayRepoId = settingKey[String]("The project id in bintray.") | ||
val bintrayUserId = settingKey[String]("The user we have in bintray.") | ||
val bintrayPublishToUrl = settingKey[String]("The url we'll publish to.") | ||
val bintrayLayout = settingKey[String]("pattern we use when publishing to bintray.") | ||
// val bintrayPluginUrl = "https://api.bintray.com/content/sbt/sbt-plugin-releases/" | ||
//val bintrayPluginLayout = "[module]/[revision]/"+ Resolver.localBasePattern | ||
|
||
def bintrayCreds(creds: Seq[sbt.Credentials]): (String, String) = { | ||
val matching = | ||
for { | ||
c <- creds | ||
if c.isInstanceOf[sbt.DirectCredentials] | ||
val cred = c.asInstanceOf[sbt.DirectCredentials] | ||
if cred.host == "api.bintray.com" | ||
} yield cred.userName -> cred.passwd | ||
|
||
matching.headOption getOrElse sys.error("Unable to find bintray credentials (api.bintray.com)") | ||
} | ||
|
||
def publishContent(pkg: String, subject: String, repo: String, version: String, creds: Seq[sbt.Credentials]): Unit = { | ||
val uri = s"https://bintray.com/api/v1/content/$subject/$repo/$pkg/$version/publish" | ||
val (u,p) = bintrayCreds(creds) | ||
import dispatch.classic._ | ||
// TODO - Log the output | ||
Http(url(uri).POST.as(u,p).>|) | ||
} | ||
|
||
def settings: Seq[Setting[_]] = | ||
Seq( | ||
bintrayRepoId := "sbt-plugin-releases", | ||
bintrayUserId := "sbt", | ||
bintrayLayout := s"${normalizedName.value}/[revision]/${Resolver.localBasePattern}", | ||
bintrayPublishToUrl := s"https://api.bintray.com/content/${bintrayUserId.value}/${bintrayRepoId.value}/", | ||
publishTo := { | ||
val resolver = Resolver.url("bintray-"+bintrayRepoId.value, new URL(bintrayPublishToUrl.value))(Patterns(false, bintrayLayout.value)) | ||
Some(resolver) | ||
}, | ||
checkBintrayCredentials := { | ||
val creds = credentials.value | ||
val (user, _) = bintrayCreds(creds) | ||
streams.value.log.info(s"Using $user for bintray login.") | ||
}, | ||
bintrayPublishAllStaged := { | ||
val creds = credentials.value | ||
publishContent(projectID.value.name, bintrayUserId.value, bintrayRepoId.value, version.value, creds) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Should this whole thing be a plugin on it's own?