-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled automated, sequenced releases from Travis CI (#1387)
The goal is to release automatically from Travis and enable convenient merging of PRs, even if many PRs are merged concurrently (bug in Shipkit Gradle plugin: mockito/shipkit#395). - instead of using Shipkit Gradle plugin we keep most CI/CD automation inside Ambry project. This way, it is easier to configure, debug and understand. - we're using a new Gradle plugin "shipkit-auto-version". This plugin automatically deducts the version based on the most recent tag and the "version.properties" file. It is a very simple plugin, keeps the build logic simple, and keeps the Ambry build easy to maintain in the future. This PR removes following features (acceptable trade-offs, we can implement it in the future): - automated release notes generation
- Loading branch information
1 parent
64b257e
commit 07b00a9
Showing
8 changed files
with
162 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
task bintrayUploadAll { | ||
description = "Runs 'bintrayUpload' tasks from all projects" | ||
mustRunAfter "gitPush" //git push is easier to rollback so we run it first | ||
} | ||
|
||
allprojects { | ||
tasks.matching { it.name == "bintrayUpload" }.all { | ||
bintrayUploadAll.dependsOn it | ||
} | ||
} | ||
|
||
task ciPerformRelease { | ||
description = "Performs the release, intended to be ran on CI" | ||
dependsOn "gitTag", "gitPush", "bintrayUploadAll" | ||
} | ||
|
||
task gitTag { | ||
description = "Creates annotated tag 'v$version'" | ||
|
||
doLast { | ||
println "Setting Git user and email to Travis CI" | ||
exec { commandLine "git", "config", "user.email", "travis@travis-ci.org" } | ||
exec { commandLine "git", "config", "user.name", "Travis CI" } | ||
println "Creating tag v$version" | ||
exec { commandLine "git", "tag", "-a", "-m", "Release $version", "v$version" } | ||
println "Created tag v$version" | ||
} | ||
} | ||
|
||
task gitPush(type: Exec) { | ||
description = "Pushes tags by running 'git push --tags'. Hides secret key from git push output." | ||
mustRunAfter "gitTag" //tag first, push later | ||
|
||
doFirst { println "Pushing tag v$version" } | ||
commandLine "./gradle/git-push.sh", "v$version" | ||
doLast { println "Pushed tag v$version" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
#Git push is implemented in the script to make sure we are not leaking GH key to the output | ||
#Expects 'GIT_SECRET' env variable to be in format: user:github_access_token, | ||
#for example: mockitoguy:qq43234xc23x23d24d | ||
|
||
echo "Running git push without output for security. If it fails make sure that GIT_SECRET env variable is set." | ||
git push --quiet https://$GIT_SECRET@github.com/linkedin/ambry.git --tags > /dev/null 2>&1 | ||
EXIT_CODE=$? | ||
echo "'git push --quiet' exit code: $EXIT_CODE" | ||
exit $EXIT_CODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
assert plugins.hasPlugin("java") | ||
|
||
apply plugin: 'maven-publish' | ||
apply plugin: 'com.jfrog.bintray' | ||
|
||
tasks.withType(Jar) { | ||
from "$rootDir/LICENSE" | ||
from "$rootDir/NOTICE" | ||
} | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
task testJar(type: Jar, dependsOn: testClasses) { | ||
from sourceSets.test.output | ||
classifier = 'test' | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar | ||
archives javadocJar | ||
archives testJar | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
from components.java | ||
|
||
artifact javadocJar | ||
artifact sourcesJar | ||
artifact testJar | ||
} | ||
} | ||
} | ||
|
||
bintray { //docs: https://github.com/bintray/gradle-bintray-plugin | ||
user = System.getenv("BINTRAY_USER") | ||
key = System.getenv("BINTRAY_API_KEY") | ||
|
||
publish = true | ||
dryRun = project.hasProperty("bintray.dryRun")? true : false //useful for testing | ||
|
||
publications = ['maven'] | ||
|
||
pkg { | ||
repo = 'test-repo' | ||
userOrg = 'linkedin' | ||
name = 'ambry' | ||
|
||
licenses = ['Apache-2.0'] | ||
labels = ['blob storage'] | ||
version { | ||
// disable gpg signing to speed up publishing | ||
gpg { | ||
sign = false | ||
} | ||
// disable upload to maven central | ||
mavenCentralSync { | ||
sync = false | ||
} | ||
} | ||
} | ||
} | ||
|
||
bintrayUpload { | ||
doFirst { | ||
println "Publishing $jar.baseName to Bintray (dryRun: $dryRun, repo: $repoName, publish: $publish)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
# exit when any command fails | ||
set -e | ||
|
||
echo "Building and testing artifacts, and creating pom files" | ||
./gradlew -s --scan build publishToMavenLocal codeCoverageReport | ||
|
||
echo "Testing Bintray publication by uploading in dry run mode" | ||
./gradlew -s -i --scan bintrayUploadAll -Pbintray.dryRun | ||
|
||
echo "Pull request: [$TRAVIS_PULL_REQUEST], Travis branch: [$TRAVIS_BRANCH]" | ||
# release only from master when no pull request build | ||
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] | ||
then | ||
echo "Releasing (tagging, uploading to Bintray)" | ||
./gradlew -s -i --scan ciPerformRelease | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#Version of the produced binaries. This file is intended to be checked-in. | ||
#It will be automatically bumped by release automation. | ||
version=0.3.110 | ||
previousVersion=0.3.109 | ||
# shipkit-auto-version Gradle plugin uses this version spec to deduct the version to build | ||
# it increments patch version based on most recent tag. | ||
# You can put explicit version here if needed, e.g. "1.0.0" | ||
# More information: https://github.com/shipkit/shipkit-auto-version/blob/master/README.md | ||
version=0.3.* |