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

starts the effort to simplify artifact release #995

Merged
merged 4 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should just give up on built matrix and start using build.sh? It seems to be what Flavio is doing for Arrows (https://github.com/traneio/arrows/blob/master/.travis.yml).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fwbrasil i see you went through a couple of different iterations on doing cross builds to finally hardcoding 2.12 in your build script. Any helpful gotchas that you discovered in the process?

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"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add local.* into .gitignore?

Copy link
Collaborator

@vkostyukov vkostyukov Oct 9, 2018

Choose a reason for hiding this comment

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

Also, what's interesting is I have gpg 2.2.10 installed locally and it doesn't use the secring.gpg file (according to this doc):

A secret keyring as used by GnuPG versions before 2.1. It is not used by GnuPG 2.1 and later.

I'm not sure which version of gpg utility sbt-gpg depends on so perhaps I should downgrade to make sure I generate both files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nevermind. I'll modify the .gitignore in my separate branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding to the .gitignore makes sense to me to prevent accidental commits. As to the GPG situation i can look into the sbt-release plugin to see what version that it supports. Maybe that's no longer a required setting for newer versions of GPG.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I decided to use the older version of GPG I installed via brew. I'm pretty sure that version works just fine with sbt-gpg plugin:

$ gpg --version
gpg (GnuPG) 1.4.18
Copyright (C) 2014 Free Software Foundation, Inc.

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does commit the new version back? Or maybe we aren't doing it yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The magic seems to be part of the sbt-release functionality defined here
https://github.com/sbt/sbt-release/blob/v1.0.9/src/main/scala/ReleaseExtra.scala#L77-L93

Used as part of the release process defined here https://github.com/finagle/finch/pull/995/files#diff-fdc3abdfd754eeb24090dbd90aeec2ceR131

TBH, i haven't tested the release process yet. I have an internal jfrog account where i can test with a sandbox repo. Maybe i can create a dummy repo to test out the versioning. I also need to read up a bit more on sbt-release and understand how the next version gets promoted. In theory it should be 0.26.0-SNAPSHOT when a new release is performed. Maybe setting to 1.0.0-SNAPSHOT is a manual step before committing to the 1.0.0 milestone

Wasn't super familiar with this plugin but seems like it can do a bit more than what is currently being done. Seems like it can apparently automate release notes?

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"