Skip to content

Commit

Permalink
starts the effort to simplify artifact release (#995)
Browse files Browse the repository at this point in the history
* starts the effort to simplify artifact release
* lint fix
* hardcoded name and email
  • Loading branch information
arron-green authored and vkostyukov committed Oct 9, 2018
1 parent 3079e72 commit e951831
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: scala
sudo: false
branches:
except:
- release
sudo: true
scala:
- 2.11.12
- 2.12.6
Expand All @@ -13,7 +16,8 @@ cache:
- "$HOME/.ivy2/cache"
- "$HOME/.sbt/boot/"
script:
- sbt ++$TRAVIS_SCALA_VERSION validate
- sbt ++$TRAVIS_SCALA_VERSION validate
# - "./build/build.sh"
after_success:
- bash <(curl -s https://codecov.io/bash)
env:
Expand Down
51 changes: 50 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import microsites.ExtraMdFileConfig
import sbtrelease.ReleasePlugin
import ReleaseTransformations._

lazy val buildSettings = Seq(
organization := "com.github.finagle",
version := "0.24.0",
scalaVersion := "2.12.7",
crossScalaVersions := Seq("2.11.12", "2.12.7")
)
Expand Down Expand Up @@ -64,6 +65,33 @@ val baseSettings = Seq(
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 @@ -75,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 @@ -85,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
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 ++${TRAVIS_SCALA_VERSION} 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
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"

0 comments on commit e951831

Please sign in to comment.