mirror of https://github.com/sbt/sbt.git
Fix publishing to bintray to automatically make artifacts available after succesful upload.
This commit is contained in:
parent
2f6c444fd5
commit
f51c51edbe
|
|
@ -15,6 +15,7 @@ object Packaging {
|
||||||
val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/"
|
val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/"
|
||||||
val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/"
|
val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/"
|
||||||
val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/"
|
val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/"
|
||||||
|
val bintrayPublishAllStaged = TaskKey[Unit]("bintray-publish-all-staged", "Publish all staged artifacts on bintray.")
|
||||||
|
|
||||||
// Note: The legacy api.
|
// Note: The legacy api.
|
||||||
//val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages"
|
//val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages"
|
||||||
|
|
@ -31,9 +32,9 @@ object Packaging {
|
||||||
/** Returns an id, url and pattern for publishing based on the given configuration. */
|
/** Returns an id, url and pattern for publishing based on the given configuration. */
|
||||||
def getPublishSettings(config: Configuration): (String, String, String) =
|
def getPublishSettings(config: Configuration): (String, String, String) =
|
||||||
config.name match {
|
config.name match {
|
||||||
case Debian.name => ("bintray-debian", bintrayDebianUrl, bintrayLinuxPattern)
|
case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern)
|
||||||
case Rpm.name => ("bintray-rpm", bintrayRpmUrl, bintrayLinuxPattern)
|
case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern)
|
||||||
case _ => ("generic-native-packages-" + config.name, bintrayGenericPackagesUrl, bintrayGenericPattern)
|
case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
def makePublishTo(id: String, url: String, pattern: String): Setting[_] = {
|
def makePublishTo(id: String, url: String, pattern: String): Setting[_] = {
|
||||||
|
|
@ -45,14 +46,52 @@ object Packaging {
|
||||||
|
|
||||||
def makePublishToForConfig(config: Configuration) = {
|
def makePublishToForConfig(config: Configuration) = {
|
||||||
val (id, url, pattern) = getPublishSettings(config)
|
val (id, url, pattern) = getPublishSettings(config)
|
||||||
|
|
||||||
|
|
||||||
// Add the publish to and ensure global resolvers has the resolver we just configured.
|
// Add the publish to and ensure global resolvers has the resolver we just configured.
|
||||||
inConfig(config)(Seq(makePublishTo(id, url, pattern))) ++
|
inConfig(config)(Seq(
|
||||||
Seq(resolvers <++= (publishTo in config) apply (_.toSeq))
|
makePublishTo(id, url, pattern),
|
||||||
|
bintrayPublishAllStaged <<= (credentials, version) map { (creds, version) =>
|
||||||
|
publishContent(id, version, creds)
|
||||||
|
},
|
||||||
|
// TODO - This is a little funky...
|
||||||
|
publish <<= (publish, credentials, version) apply { (publish, creds, version) =>
|
||||||
|
for {
|
||||||
|
pub <- publish
|
||||||
|
creds <- creds
|
||||||
|
} yield publishContent(id, version, creds)
|
||||||
|
}
|
||||||
|
)) ++ Seq(
|
||||||
|
resolvers <++= (publishTo in config) apply (_.toSeq)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def publishToSettings: Seq[Setting[_]] =
|
def publishToSettings: Seq[Setting[_]] =
|
||||||
Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig
|
Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig
|
||||||
|
|
||||||
|
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(repo: String, version: String, creds: Seq[sbt.Credentials]): Unit = {
|
||||||
|
val subject = "sbt" // Sbt org
|
||||||
|
val pkg = "sbt" // Sbt package
|
||||||
|
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).>|)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ publishToSettings ++ Seq(
|
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ publishToSettings ++ Seq(
|
||||||
sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion,
|
sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion,
|
||||||
|
|
@ -123,6 +162,7 @@ object Packaging {
|
||||||
|
|
||||||
// Universal ZIP download install.
|
// Universal ZIP download install.
|
||||||
name in Universal := "sbt",
|
name in Universal := "sbt",
|
||||||
|
version in Universal <<= sbtVersion,
|
||||||
mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" },
|
mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" },
|
||||||
|
|
||||||
// Misccelaneous publishing stuff...
|
// Misccelaneous publishing stuff...
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue