diff --git a/buildscripts/kokoro/linux_artifacts.cfg b/buildscripts/kokoro/linux_artifacts.cfg index 46263cf29f..0938e4bff2 100644 --- a/buildscripts/kokoro/linux_artifacts.cfg +++ b/buildscripts/kokoro/linux_artifacts.cfg @@ -6,6 +6,7 @@ timeout_mins: 60 action { define_artifacts { - regex: ["**/mvn-artifacts/**"] + regex: "github/grpc-java/mvn-artifacts/**" + regex: "github/grpc-java/artifacts/**" } } diff --git a/buildscripts/kokoro/macos.cfg b/buildscripts/kokoro/macos.cfg index 50c0da6cdc..310e113041 100644 --- a/buildscripts/kokoro/macos.cfg +++ b/buildscripts/kokoro/macos.cfg @@ -15,6 +15,6 @@ env_vars { # We always build mvn artifacts. action { define_artifacts { - regex: ["**/mvn-artifacts/**"] + regex: "github/grpc-java/mvn-artifacts/**" } } diff --git a/buildscripts/kokoro/unix.sh b/buildscripts/kokoro/unix.sh index a559aa42ee..353717e336 100755 --- a/buildscripts/kokoro/unix.sh +++ b/buildscripts/kokoro/unix.sh @@ -88,8 +88,16 @@ if [[ -z "${ALL_ARTIFACTS:-}" ]]; then ./gradlew grpc-compiler:build grpc-compiler:publish $GRADLE_FLAGS \ -Dorg.gradle.parallel=false -PrepositoryDir=$LOCAL_MVN_TEMP else - ./gradlew publish $GRADLE_FLAGS \ + ./gradlew publish :grpc-core:versionFile $GRADLE_FLAGS \ -Dorg.gradle.parallel=false -PrepositoryDir=$LOCAL_MVN_TEMP + pushd examples/example-hostname + ../gradlew jibBuildTar $GRADLE_FLAGS + popd + + readonly OTHER_ARTIFACT_DIR="${OTHER_ARTIFACT_DIR:-$GRPC_JAVA_DIR/artifacts}" + mkdir -p "$OTHER_ARTIFACT_DIR" + cp core/build/version "$OTHER_ARTIFACT_DIR"/ + cp examples/example-hostname/build/example-hostname.* "$OTHER_ARTIFACT_DIR"/ fi readonly MVN_ARTIFACT_DIR="${MVN_ARTIFACT_DIR:-$GRPC_JAVA_DIR/mvn-artifacts}" diff --git a/buildscripts/kokoro/upload_artifacts.sh b/buildscripts/kokoro/upload_artifacts.sh index c3c97444dc..c56cddf8f8 100644 --- a/buildscripts/kokoro/upload_artifacts.sh +++ b/buildscripts/kokoro/upload_artifacts.sh @@ -12,6 +12,7 @@ find "$KOKORO_GFILE_DIR" # The output from all the jobs are coalesced into a single dir LOCAL_MVN_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/mvn-artifacts/ +LOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/ # verify that files from all 3 grouped jobs are present. # platform independent artifacts, from linux job: @@ -45,6 +46,9 @@ mkdir -p ~/java_signing/ gsutil cp -r gs://grpc-testing-secrets/java_signing/ ~/ gpg --batch --import ~/java_signing/grpc-java-team-sonatype.asc +gsutil cat gs://grpc-testing-secrets/dockerhub_credentials/grpcpackages.password \ + | docker login --username grpcpackages --password-stdin + # gpg commands changed between v1 and v2 are different. gpg --version @@ -65,5 +69,19 @@ if gpg --version | grep 'gpg (GnuPG) 2.'; then --detach-sign -a {} \; fi +# Just the numbers; does not include leading 'v' +VERSION="$(cat $LOCAL_OTHER_ARTIFACTS/version)" +EXAMPLE_HOSTNAME_ID="$(cat "$LOCAL_OTHER_ARTIFACTS/example-hostname.id")" +docker load --input "$LOCAL_OTHER_ARTIFACTS/example-hostname.tar" +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)" + + STAGING_REPO=a93898609ef848 "$GRPC_JAVA_DIR"/buildscripts/sonatype-upload.sh "$STAGING_REPO" "$LOCAL_MVN_ARTIFACTS" + +docker tag "$EXAMPLE_HOSTNAME_ID" "grpc/java-example-hostname:${VERSION}" +docker push "grpc/java-example-hostname:${VERSION}" +if [[ "$VERSION" = "$LATEST_VERSION" ]]; then + docker tag "$EXAMPLE_HOSTNAME_ID" grpc/java-example-hostname:latest + docker push grpc/java-example-hostname:latest +fi diff --git a/buildscripts/kokoro/windows.cfg b/buildscripts/kokoro/windows.cfg index 0002fd1571..6b2703f99c 100644 --- a/buildscripts/kokoro/windows.cfg +++ b/buildscripts/kokoro/windows.cfg @@ -7,6 +7,7 @@ timeout_mins: 45 # We always build mvn artifacts. action { define_artifacts { - regex: ["**/build/test-results/**/*.xml", "**/mvn-artifacts/**"] + regex: "**/build/test-results/**/*.xml" + regex: "github/grpc-java/mvn-artifacts/**" } } diff --git a/core/build.gradle b/core/build.gradle index 50fc7a282b..8ae917db50 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -56,3 +56,9 @@ plugins.withId("java") { options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF) } } + +task versionFile() { + doLast { + new File(buildDir, "version").write("${project.version}\n") + } +} diff --git a/examples/example-hostname/build.gradle b/examples/example-hostname/build.gradle index 6d1c824a81..8a521b442a 100644 --- a/examples/example-hostname/build.gradle +++ b/examples/example-hostname/build.gradle @@ -3,6 +3,7 @@ plugins { id 'java' id "com.google.protobuf" version "0.8.10" + id 'com.google.cloud.tools.jib' version '2.1.0' // For releasing to Docker Hub } repositories { @@ -52,3 +53,13 @@ protobuf { applicationName = 'hostname-server' mainClassName = 'io.grpc.examples.hostname.HostnameServer' + +// For releasing to Docker Hub +jib { + container.ports = ['50051'] + outputPaths { + tar = 'build/example-hostname.tar' + digest = 'build/example-hostname.digest' + imageId = 'build/example-hostname.id' + } +}