-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Kokoro build scripts. (GoogleCloudPlatform#69)
* Adds Kokoro build scripts. * Changes to use gradle-release plugin.
- Loading branch information
Showing
5 changed files
with
215 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Fail on any error. | ||
set -e | ||
# Display commands to stderr. | ||
set -x | ||
|
||
cd github/endpoints-framework-gradle-plugin | ||
./gradlew check prepareRelease |
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,67 @@ | ||
#!/bin/bash | ||
|
||
# Fail on any error. | ||
set -e | ||
|
||
CREDENTIALS="$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | ||
|
||
# Display commands to stderr. | ||
set -x | ||
|
||
# Goes to the GCS directory. | ||
cd $KOKORO_GFILE_DIR | ||
|
||
# Finds the latest ubuntu/release-sign build directory. | ||
LAST_BUILD=$(ls prod/endpoints-framework-gradle-plugin/ubuntu/release-sign/ | sort -rV | head -1) | ||
|
||
# Finds the bundled jar file in the latest signed artifact directory. | ||
BUNDLED_JAR_FILE=$(find `pwd`/prod/endpoints-framework-gradle-plugin/ubuntu/release-sign/${LAST_BUILD}/* -type f \( -iname \*-bundle.jar \)) | ||
|
||
# Usage: GetSessionID <variable name> | ||
# Uses the environment variable CREDENTIALS. | ||
# Stores the Nexus session ID in the given variable. | ||
GetSessionID() { | ||
local __resultvar=$1 | ||
|
||
# Makes a temporary file to store the login cookies. | ||
local cookies_temp=$(mktemp /tmp/sonatype_cookies.XXXXXXX) | ||
|
||
# Sends a login request. | ||
{ local login_response=$(curl 'https://oss.sonatype.org/service/local/authentication/login' -X 'GET' -u "$CREDENTIALS" -c $cookies_temp 2> /dev/null); } 2> /dev/null | ||
|
||
# Checks if login was successful. | ||
echo $login_response | grep -q '<loggedIn>true</loggedIn>' | ||
|
||
local login_check=$(echo -n $?) | ||
|
||
if [ "$login_check" -eq "1" ]; then | ||
return 1 | ||
fi | ||
|
||
# Extracts the session ID from the cookies. | ||
local nxsessionid | ||
local nxsessionid_line=$(cat $cookies_temp | grep 'NXSESSIONID') | ||
nxsessionid=$(echo -n $nxsessionid_line | awk '{print $NF}') | ||
|
||
eval $__resultvar="'$nxsessionid'" | ||
} | ||
|
||
# Usage: UploadJAR <session ID> <file> | ||
# Uploads the bundled JAR file to the Nexus Staging Repository. | ||
UploadJAR() { | ||
curl 'https://oss.sonatype.org/service/local/staging/bundle_upload' -H "Cookie: NXSESSIONID=$1" -H 'Content-Type: multipart/form-data' --compressed -F "file=@$2" | ||
} | ||
|
||
# Gets the session ID. | ||
GetSessionID NXSESSIONID | ||
if [ $? -eq 1 ]; then | ||
echo 'Login failed!' | ||
exit 1 | ||
fi | ||
echo 'Login successful.' | ||
|
||
# Uploads the bundled JAR file. | ||
echo 'Uploading artifact...' | ||
UploadJAR $NXSESSIONID $BUNDLED_JAR_FILE | ||
|
||
# TODO: Release on Sonatype. |
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,35 @@ | ||
#!/bin/bash | ||
|
||
# Fail on any error. | ||
set -e | ||
# Display commands being run. | ||
set -x | ||
|
||
cd $KOKORO_GFILE_DIR | ||
mkdir signed && chmod 777 signed | ||
|
||
# find the latest directory under prod/endpoints-framework-gradle-plugin/gcp_ubuntu/release-build/ | ||
LAST_BUILD=$(ls prod/endpoints-framework-gradle-plugin/gcp_ubuntu/release-build/ | sort -rV | head -1) | ||
|
||
# find the jars and the pom in the latest build artifact directory | ||
FILES=$(find `pwd`/prod/endpoints-framework-gradle-plugin/gcp_ubuntu/release-build/${LAST_BUILD}/* -type f \( -iname \*.jar -o -iname \*.pom \)) | ||
|
||
for f in $FILES | ||
do | ||
echo "Processing $f file..." | ||
filename=$(basename "$f") | ||
mv $f signed/$filename | ||
if /escalated_sign/escalated_sign.py -j /escalated_sign_jobs -t linux_gpg_sign \ | ||
`pwd`/signed/$filename | ||
then echo "Signed $filename" | ||
else | ||
echo "Could not sign $filename" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# bundle the artifacts for manual deploy to the Maven staging repository | ||
cd signed | ||
POM_NAME=$(ls *.pom) | ||
BUNDLE_NAME=${POM_NAME%.pom}-bundle.jar | ||
jar -cvf ${BUNDLE_NAME} * |
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,95 @@ | ||
/* | ||
* Copyright (c) 2017 Google Inc. All Right Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
// This script contains | ||
// 1. The release builder (for building releasable bundles) | ||
// 2. The release helper (for git tagging and version automation) | ||
|
||
// Release builder (provides prepareRelease script) | ||
apply plugin: 'maven' | ||
|
||
task sourceJar(type: Jar) { | ||
from sourceSets.main.allJava | ||
classifier 'sources' | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
from javadoc.destinationDir | ||
classifier = 'javadoc' | ||
} | ||
|
||
task writePom { | ||
project.afterEvaluate { | ||
def outputFile = file("$buildDir/pom/${project.name}-${project.version}.pom") | ||
outputs.file outputFile | ||
|
||
doLast { | ||
pom { | ||
project { | ||
name 'Endpoints Framework Gradle Plugin' | ||
description 'This Gradle plugin provides tasks and configurations to generate Google Cloud Endpoints Framework client code and discovery docs' | ||
url 'https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin' | ||
inceptionYear '2016' | ||
|
||
scm { | ||
url 'https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin' | ||
connection 'scm:https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin.git' | ||
developerConnection 'scm:git://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin.git' | ||
} | ||
|
||
licenses { | ||
license { | ||
name 'The Apache Software License, Version 2.0' | ||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
distribution 'repo' | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id 'loosebazooka' | ||
name 'Appu Goundan' | ||
email '[email protected]' | ||
} | ||
} | ||
} | ||
}.writeTo(outputFile) | ||
} | ||
} | ||
} | ||
|
||
task prepareRelease(type: Copy) { | ||
from jar | ||
from sourceJar | ||
from javadocJar | ||
from writePom | ||
|
||
into "${buildDir}/release-artifacts" | ||
|
||
dependsOn build | ||
dependsOn cleanPrepareRelease | ||
} | ||
|
||
// Release helper (git release commits and version updates) | ||
apply plugin: 'net.researchgate.release' | ||
|
||
release { | ||
tagTemplate = 'v$version' | ||
git { | ||
requireBranch = /^release_v\d+.*$/ //regex | ||
} | ||
} |