Modify publishing to send packages into bintray.

* Use rpm repository for rpms
* Use debian repository for debians
* Use generic repository for everything else.

Note: we still need to mark a release as public afterwards with an API call.  Need to figure that one out for automation.
This commit is contained in:
Josh Suereth 2013-09-04 11:50:58 -04:00
parent 089a0efbca
commit 44b651d607
3 changed files with 38 additions and 15 deletions

View File

@ -1,18 +1,8 @@
sbtPlugin := true
name := "sbt-launcher-package"
organization := "org.scala-sbt"
name := "sbt-launcher-packaging"
version := "0.1.0"
crossTarget <<= target
publishTo in Global := {
val nativeReleaseUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages"
val nativeReleasePattern = "[organization]/[module]/[revision]/[module].[ext]"
val resolver = Resolver.url("native-releases", new URL(nativeReleaseUrl))(Patterns(nativeReleasePattern))
// Resolver.file("native-releases-local", file("/home/jsuereth/repos/native-packages"))(Patterns(nativeReleasePattern))
Some(resolver)
}

View File

@ -1 +1 @@
sbt.version=0.12.4-RC1
sbt.version=0.12.4

View File

@ -12,7 +12,15 @@ object Packaging {
val stagingDirectory = SettingKey[File]("staging-directory")
val stage = TaskKey[File]("stage")
def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]"
val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]"
val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/"
val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/"
val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/"
// Note: The legacy api.
//val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages"
//val genericNativeReleasesPattern = "[organisation]/[module]/[revision]/[module].[ext]"
import util.control.Exception.catching
@ -22,8 +30,33 @@ object Packaging {
case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar"
case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar"
}
/** Returns an id, url and pattern for publishing based on the given configuration. */
def getPublishSettings(config: Configuration): (String, String, String) =
config.name match {
case Debian.name => ("bintray-debian", bintrayDebianUrl, bintrayLinuxPattern)
case Rpm.name => ("bintray-rpm", bintrayRpmUrl, bintrayLinuxPattern)
case _ => ("generic-native-packages-" + config.name, bintrayGenericPackagesUrl, bintrayGenericPattern)
}
def makePublishTo(id: String, url: String, pattern: String): Setting[_] = {
publishTo := {
val resolver = Resolver.url(id, new URL(url))(Patterns(pattern))
Some(resolver)
}
}
def makePublishToForConfig(config: Configuration) = {
val (id, url, pattern) = getPublishSettings(config)
// Add the publish to and ensure global resolvers has the resolver we just configured.
inConfig(config)(Seq(makePublishTo(id, url, pattern))) ++
Seq(resolvers <++= (publishTo in config) apply (_.toSeq))
}
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ Seq(
def publishToSettings: Seq[Setting[_]] =
Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ publishToSettings ++ Seq(
sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion,
sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"),
sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) =>