diff --git a/.drone.sec b/.drone.sec new file mode 100644 index 00000000..66e29017 --- /dev/null +++ b/.drone.sec @@ -0,0 +1 @@ +eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.oppx3cSUjhzo5xCsV3FPEZd5Q6lhpDUnpx61GUsiuImgfC5zTd-emiJX8vV9vBHMKe_iiiCVPIGOpvqp6TIxZ7q92T28eEJGn6D1r1mwlXFpR21SV9OkUqDqtNWQMbYZKKd3fiFlrKa1_EB-8ivS3kIOUlryeAVHQfKE28s1YGkCq7hEeSfIAE9NW3Imu5hL29V4RU8PRMr_j2Nc_Fu86kGgZ7nEUfxDpqsn-mrSnTlALDARu709WTeZ3qgLl51LoXCnCcgjvsNh88UI_3BQtAJQg5OQN6Fu6tdCDCYB6_fB4R2eRRsAewUt_oHKskcwz-Es80uRJO3reNRcg_wnMg.ioaBTHD5-_-EKtSs.D_kiy4tzK6QsJRQi4z5xEY131o5cwXTOjwGcm6uRc8nDu8SU3s7h5GA0NwkG-35qExaSq7R_FwyfT5E8Qpdau0vHf359YJA6PcaUcC6mml6LGgldCiwurX50oAqZmwZyglHRqu3o6-X2gW8Kr856berPmco1hPNfA4AJ9N-_MS61urFY02ejuguxLW-k6IoHJfTlm3PLcdkvHpcLMh6D6pFZnBVbTzTqnA7Xhtf6PqsS.IqA2b51Hdgr-2wCrGsEFBA \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index 20a18770..1a5b7c06 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,8 +1,18 @@ build: - image: olafurpg/scalafix:0.0.1 - commands: - - ./bin/scalafmt --version 0.4.5 --test - - sbt clean test + tests: + image: olafurpg/scalafix:0.0.1 + commands: + - ./bin/scalafmt --version 0.4.5 --test + - sbt clean test + publish: + image: olafurpg/scalafix:0.0.1 + environment: + - BINTRAY_USERNAME=$$BINTRAY_USERNAME + - BINTRAY_API_KEY=$$BINTRAY_API_KEY + commands: + - ./bin/bintray.sh + when: + branch: [master, 4.x] cache: mount: - $HOME/.scalafmt-bin diff --git a/bin/bintray.sh b/bin/bintray.sh new file mode 100755 index 00000000..3de8022c --- /dev/null +++ b/bin/bintray.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if [[ "$CI_BRANCH" == "master" || "$CI_BRANCH" == "4.x" ]]; then + PUBLISH=publish + mkdir -p ~/.bintray + cat > ~/.bintray/.credentials < slimJar), overwrite = true) (art, slimJar) }, - publishMavenStyle := true, + publishMavenStyle := !isSnapshot, publishArtifact in Compile := true, - publishTo <<= version { v: String => + publishTo := { val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") + println("PRVERSION: " + PRVersion) + if (PRVersion.isDefined) (publishTo in bintray).value + else if (isSnapshot) Some("snapshots" at nexus + "content/repositories/snapshots") + else Some("releases" at nexus + "service/local/staging/deploy/maven2") }, pomIncludeRepository := { x => false }, + bintrayOrganization := Some("scalameta"), + licenses += + "BSD" -> url("https://github.com/scalameta/paradise/blob/master/LICENSE.md"), pomExtra := ( https://github.com/scalameta/paradise 2012 @@ -191,8 +199,8 @@ lazy val plugin = Project(id = "paradise", base = file("plugin")) http://xeno.by - ), - credentials ++= loadCredentials() + ) +// , credentials ++= loadCredentials() ) lazy val testsCommon = project @@ -233,3 +241,26 @@ lazy val testsConverter = project exposePaths("testsConverter", Test) ) .dependsOn(testsCommon, plugin) + +def parsePullRequestFromCommitMessage: Option[String] = { + import sys.process._ + val PullRequest = "\\s+Merge pull request #(\\d+).*".r + for { + commitMsg <- Try(Seq("git", "log", "-1").!!.trim).toOption + pr <- augmentString(commitMsg).lines.collectFirst { + case PullRequest(pr) => pr + } + } yield pr +} + +/** Replaces -SNAPSHOT with latest pull request number, if it exists.j */ +def latestPullRequestVersion(): Option[String] = { + for { + _ <- sys.env.get("BINTRAY_API_KEY") + if isSnapshot + if !sys.env.contains("CI_PULL_REQUEST") + pullRequest <- parsePullRequestFromCommitMessage + } yield { + LibraryVersion.replace("-SNAPSHOT", s".$pullRequest") + } +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 512b366a..aa33119d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,5 @@ +addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") + addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M14") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")