Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auto releases #1000

Merged
merged 12 commits into from
Oct 9, 2018
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ target/
.cache
.settings
.project
.classpath
.classpath
local.*
25 changes: 14 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
language: scala
sudo: false
scala:
- 2.11.12
- 2.12.6
branches:
except:
- release
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arron-green Do you know what's release branch is for?

sudo: true
jdk:
- oraclejdk8
- oraclejdk8
before_cache:
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
- "$HOME/.ivy2/cache"
- "$HOME/.sbt/boot/"
script:
- sbt ++$TRAVIS_SCALA_VERSION validate
- "./build/build.sh"
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
env:
global:
secure: llQnDN9mZTL03lIqF8V2Z247C31H5pMJscZufTaKh5yFeTOhT0rJVBPjIfei25g6oc7kEPIYOf4YgKEUfokDvXnjfIZoJmb4YQJCctwZ6itFK4g49myJfXFIts1GUSBwbT4KmiHtFIzN/zNRAYrX3Tn3BC5T4X99ugGnHMGkBss=
65 changes: 57 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import microsites.ExtraMdFileConfig
import sbtrelease.ReleasePlugin
import ReleaseTransformations._

lazy val buildSettings = Seq(
organization := "com.github.finagle",
version := "0.24.0",
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.11.12", "2.12.6")
scalaVersion := "2.12.7",
crossScalaVersions := Seq("2.11.12", "2.12.7")
)

lazy val twitterVersion = "18.9.0"
lazy val circeVersion = "0.9.3"
lazy val circeIterateeVersion = "0.10.0"
lazy val circeVersion = "0.10.0"
lazy val circeIterateeVersion = "0.11.0"
lazy val shapelessVersion = "2.3.3"
lazy val catsVersion = "1.4.0"
lazy val argonautVersion = "6.2.2"
Expand Down Expand Up @@ -59,9 +60,38 @@ val baseSettings = Seq(
scalacOptions in (Compile, console) ~= {
_.filterNot(Set("-Ywarn-unused-import"))
},
scalacOptions in (Compile, console) += "-Yrepl-class-based"
scalacOptions in (Compile, console) += "-Yrepl-class-based",
fork in Test := true,
javaOptions in ThisBuild ++= Seq("-Xss2048K")
)

def updateVersionInFile(selectVersion: sbtrelease.Versions => String): ReleaseStep =
ReleaseStep(action = st => {
val newVersion = selectVersion(st.get(ReleaseKeys.versions).get)
import scala.io.Source
import java.io.PrintWriter

// files containing version to update upon release
val filesToUpdate = Seq(
"docs/src/main/tut/index.md"
)
val pattern = """"com.github.finagle" %% "finch-.*" % "(.*)"""".r

filesToUpdate.foreach { fileName =>
val content = Source.fromFile(fileName).getLines.mkString("\n")
val newContent =
pattern.replaceAllIn(content,
m => m.matched.replaceAllLiterally(m.subgroups.head, newVersion))
new PrintWriter(fileName) {
write(newContent); close()
}
val vcs = Project.extract(st).get(releaseVcs).get
vcs.add(fileName).!
}

st
})

lazy val publishSettings = Seq(
publishMavenStyle := true,
publishArtifact := true,
Expand All @@ -73,6 +103,10 @@ lazy val publishSettings = Seq(
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
pgpSecretRing := file("local.secring.gpg"),
pgpPublicRing := file("local.pubring.gpg"),
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseIgnoreUntrackedFiles := true,
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/finagle/finch")),
autoAPIMappings := true,
Expand All @@ -83,6 +117,23 @@ lazy val publishSettings = Seq(
"scm:git:[email protected]:finagle/finch.git"
)
),
releaseProcess := {
Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
releaseStepCommandAndRemaining("+clean"),
releaseStepCommandAndRemaining("+test"),
setReleaseVersion,
updateVersionInFile(_._1),
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)
},
pomExtra :=
<developers>
<developer>
Expand Down Expand Up @@ -317,8 +368,6 @@ lazy val benchmarks = project
"-XX:+CMSClassUnloadingEnabled",
"-XX:ReservedCodeCacheSize=128m",
"-XX:MaxPermSize=1024m",
"-Xss8M",
"-Xms512M",
"-XX:SurvivorRatio=128",
"-XX:MaxTenuringThreshold=0",
"-Xss8M",
Expand Down
36 changes: 36 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e

SBT_CMD="sbt +validate"

if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then
SBT_CMD+=" +coverageOff +publish"
openssl aes-256-cbc -pass env:ENCRYPTION_PASSWORD -in ./build/secring.gpg.enc -out local.secring.gpg -d
openssl aes-256-cbc -pass env:ENCRYPTION_PASSWORD -in ./build/pubring.gpg.enc -out local.pubring.gpg -d
openssl aes-256-cbc -pass env:ENCRYPTION_PASSWORD -in ./build/credentials.sbt.enc -out local.credentials.sbt -d
openssl aes-256-cbc -pass env:ENCRYPTION_PASSWORD -in ./build/deploy_key.pem.enc -out local.deploy_key.pem -d

if [[ "${TRAVIS_BRANCH}" == "master" && $(cat version.sbt) != *"SNAPSHOT"* ]]; then
eval "$(ssh-agent -s)"
chmod 600 local.deploy_key.pem
ssh-add local.deploy_key.pem
git config --global user.name "Finch CI"
git config --global user.email "[email protected]"
git remote set-url origin [email protected]:finagle/finch.git
git checkout master || git checkout -b master
git reset --hard origin/master

echo 'Performing a release'
sbt 'release cross with-defaults'
elif [[ "${TRAVIS_BRANCH}" == "master" ]]; then
echo 'Master build'
${SBT_CMD}
else
echo 'Branch build'
printf 'version in ThisBuild := "%s-SNAPSHOT"' "${TRAVIS_BRANCH}" > version.sbt
${SBT_CMD}
fi
else
echo 'PR build'
${SBT_CMD}
fi
Binary file added build/credentials.sbt.enc
Binary file not shown.
Binary file added build/deploy_key.pem.enc
Binary file not shown.
Binary file added build/pubring.gpg.enc
Binary file not shown.
Binary file added build/secring.gpg.enc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class AbstractJsonSpec extends FlatSpec with Matchers with Checkers wit

implicit def eqException: Eq[Exception] = Eq.instance((a, b) => a.getMessage == b.getMessage)

implicit def decodeException: Decoder[Exception] = Decoder.forProduct1[String, Exception]("message")(s =>
implicit def decodeException: Decoder[Exception] = Decoder.forProduct1[Exception, String]("message")(s =>
new Exception(s)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object ExampleCaseClass {
implicit val eq: Eq[ExampleCaseClass] = Eq.fromUniversalEquals

implicit val encoder: Encoder[ExampleCaseClass] =
Encoder.forProduct3[String, Int, Boolean, ExampleCaseClass]("a", "b", "c")(e => (e.a, e.b, e.c))
Encoder.forProduct3[ExampleCaseClass, String, Int, Boolean]("a", "b", "c")(e => (e.a, e.b, e.c))

implicit val decoder: Decoder[ExampleCaseClass] =
Decoder.forProduct3("a", "b", "c")(ExampleCaseClass.apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object ExampleNestedCaseClass {
implicit val eq: Eq[ExampleNestedCaseClass] = Eq.fromUniversalEquals

implicit val encoder: Encoder[ExampleNestedCaseClass] =
Encoder.forProduct5[String, Double, Long, List[Int], ExampleCaseClass, ExampleNestedCaseClass](
Encoder.forProduct5[ExampleNestedCaseClass, String, Double, Long, List[Int], ExampleCaseClass](
"string", "double", "long", "ints", "example"
)(e => (e.string, e.double, e.long, e.ints, e.example))

Expand Down
1 change: 1 addition & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version in ThisBuild := "0.25.0-SNAPSHOT"