Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1ca6e8

Browse files
committed
Automate release process for example-hostname
1 parent 1c50bca commit b1ca6e8

File tree

7 files changed

+49
-4
lines changed

7 files changed

+49
-4
lines changed

buildscripts/kokoro/linux_artifacts.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ timeout_mins: 60
66

77
action {
88
define_artifacts {
9-
regex: ["**/mvn-artifacts/**"]
9+
regex: "github/grpc-java/mvn-artifacts/**"
10+
regex: "github/grpc-java/artifacts/**"
1011
}
1112
}

buildscripts/kokoro/macos.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ env_vars {
1515
# We always build mvn artifacts.
1616
action {
1717
define_artifacts {
18-
regex: ["**/mvn-artifacts/**"]
18+
regex: "github/grpc-java/mvn-artifacts/**"
1919
}
2020
}

buildscripts/kokoro/unix.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,16 @@ if [[ -z "${ALL_ARTIFACTS:-}" ]]; then
8888
./gradlew grpc-compiler:build grpc-compiler:publish $GRADLE_FLAGS \
8989
-Dorg.gradle.parallel=false -PrepositoryDir=$LOCAL_MVN_TEMP
9090
else
91-
./gradlew publish $GRADLE_FLAGS \
91+
./gradlew publish :grpc-core:versionFile $GRADLE_FLAGS \
9292
-Dorg.gradle.parallel=false -PrepositoryDir=$LOCAL_MVN_TEMP
93+
pushd examples/example-hostname
94+
../gradlew jibBuildTar $GRADLE_FLAGS
95+
popd
96+
97+
readonly OTHER_ARTIFACT_DIR="${OTHER_ARTIFACT_DIR:-$GRPC_JAVA_DIR/artifacts}"
98+
mkdir -p "$OTHER_ARTIFACT_DIR"
99+
cp core/build/version "$OTHER_ARTIFACT_DIR"/
100+
cp examples/example-hostname/build/example-hostname.* "$OTHER_ARTIFACT_DIR"/
93101
fi
94102

95103
readonly MVN_ARTIFACT_DIR="${MVN_ARTIFACT_DIR:-$GRPC_JAVA_DIR/mvn-artifacts}"

buildscripts/kokoro/upload_artifacts.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ find "$KOKORO_GFILE_DIR"
1212

1313
# The output from all the jobs are coalesced into a single dir
1414
LOCAL_MVN_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/mvn-artifacts/
15+
LOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/
1516

1617
# verify that files from all 3 grouped jobs are present.
1718
# platform independent artifacts, from linux job:
@@ -45,6 +46,9 @@ mkdir -p ~/java_signing/
4546
gsutil cp -r gs://grpc-testing-secrets/java_signing/ ~/
4647
gpg --batch --import ~/java_signing/grpc-java-team-sonatype.asc
4748

49+
gsutil cat gs://grpc-testing-secrets/dockerhub_credentials/grpcpackages.password \
50+
| docker login --username grpcpackages --password-stdin
51+
4852
# gpg commands changed between v1 and v2 are different.
4953
gpg --version
5054

@@ -65,5 +69,19 @@ if gpg --version | grep 'gpg (GnuPG) 2.'; then
6569
--detach-sign -a {} \;
6670
fi
6771

72+
# Just the numbers; does not include leading 'v'
73+
VERSION="$(cat $LOCAL_OTHER_ARTIFACTS/version)"
74+
EXAMPLE_HOSTNAME_ID="$(cat "$LOCAL_OTHER_ARTIFACTS/example-hostname.id")"
75+
docker load --input "$LOCAL_OTHER_ARTIFACTS/example-hostname.tar"
76+
LATEST_VERSION="$((echo "v$VERSION"; git ls-remote -t https://github.com/grpc/grpc-java.git | cut -f 2 | sed s#refs/tags/##) | sort -V | tail -n 1)"
77+
78+
6879
STAGING_REPO=a93898609ef848
6980
"$GRPC_JAVA_DIR"/buildscripts/sonatype-upload.sh "$STAGING_REPO" "$LOCAL_MVN_ARTIFACTS"
81+
82+
docker tag "$EXAMPLE_HOSTNAME_ID" "grpc/java-example-hostname:${VERSION}"
83+
docker push "grpc/java-example-hostname:${VERSION}"
84+
if [[ "$VERSION" = "$LATEST_VERSION" ]]; then
85+
docker tag "$EXAMPLE_HOSTNAME_ID" grpc/java-example-hostname:latest
86+
docker push grpc/java-example-hostname:latest
87+
fi

buildscripts/kokoro/windows.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ timeout_mins: 45
77
# We always build mvn artifacts.
88
action {
99
define_artifacts {
10-
regex: ["**/build/test-results/**/*.xml", "**/mvn-artifacts/**"]
10+
regex: "**/build/test-results/**/*.xml"
11+
regex: "github/grpc-java/mvn-artifacts/**"
1112
}
1213
}

core/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ plugins.withId("java") {
5656
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
5757
}
5858
}
59+
60+
task versionFile() {
61+
doLast {
62+
new File(buildDir, "version").write("${project.version}\n")
63+
}
64+
}

examples/example-hostname/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'java'
44

55
id "com.google.protobuf" version "0.8.10"
6+
id 'com.google.cloud.tools.jib' version '2.1.0' // For releasing to Docker Hub
67
}
78

89
repositories {
@@ -52,3 +53,13 @@ protobuf {
5253

5354
applicationName = 'hostname-server'
5455
mainClassName = 'io.grpc.examples.hostname.HostnameServer'
56+
57+
// For releasing to Docker Hub
58+
jib {
59+
container.ports = ['50051']
60+
outputPaths {
61+
tar = 'build/example-hostname.tar'
62+
digest = 'build/example-hostname.digest'
63+
imageId = 'build/example-hostname.id'
64+
}
65+
}

0 commit comments

Comments
 (0)