1*e07d83d3SAndroid Build Coastguard Worker#!/bin/bash 2*e07d83d3SAndroid Build Coastguard Workerset -veux -o pipefail 3*e07d83d3SAndroid Build Coastguard Worker 4*e07d83d3SAndroid Build Coastguard Workerif [[ -f /VERSION ]]; then 5*e07d83d3SAndroid Build Coastguard Worker cat /VERSION 6*e07d83d3SAndroid Build Coastguard Workerfi 7*e07d83d3SAndroid Build Coastguard Worker 8*e07d83d3SAndroid Build Coastguard Workerreadonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)" 9*e07d83d3SAndroid Build Coastguard Worker 10*e07d83d3SAndroid Build Coastguard Workerecho "Verifying that all artifacts are here..." 11*e07d83d3SAndroid Build Coastguard Workerfind "$KOKORO_GFILE_DIR" 12*e07d83d3SAndroid Build Coastguard Worker 13*e07d83d3SAndroid Build Coastguard Worker# The output from all the jobs are coalesced into a single dir 14*e07d83d3SAndroid Build Coastguard WorkerLOCAL_MVN_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/mvn-artifacts/ 15*e07d83d3SAndroid Build Coastguard WorkerLOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/ 16*e07d83d3SAndroid Build Coastguard Worker 17*e07d83d3SAndroid Build Coastguard Worker# verify that files from all 3 grouped jobs are present. 18*e07d83d3SAndroid Build Coastguard Worker# platform independent artifacts, from linux job: 19*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'grpc-core-*.jar' | wc -l)" != '0' ]] 20*e07d83d3SAndroid Build Coastguard Worker 21*e07d83d3SAndroid Build Coastguard Worker# android artifact from linux job: 22*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'grpc-android-*.aar' | wc -l)" != '0' ]] 23*e07d83d3SAndroid Build Coastguard Worker 24*e07d83d3SAndroid Build Coastguard Worker# cronet artifact from linux job: 25*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'grpc-cronet-*.aar' | wc -l)" != '0' ]] 26*e07d83d3SAndroid Build Coastguard Worker 27*e07d83d3SAndroid Build Coastguard Worker# binder artifact from linux job: 28*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'grpc-binder-*.aar' | wc -l)" != '0' ]] 29*e07d83d3SAndroid Build Coastguard Worker 30*e07d83d3SAndroid Build Coastguard Worker# from linux job: 31*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-x86_64.exe' | wc -l)" != '0' ]] 32*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-x86_32.exe' | wc -l)" != '0' ]] 33*e07d83d3SAndroid Build Coastguard Worker 34*e07d83d3SAndroid Build Coastguard Worker# for linux aarch64 platform 35*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-aarch_64.exe' | wc -l)" != '0' ]] 36*e07d83d3SAndroid Build Coastguard Worker 37*e07d83d3SAndroid Build Coastguard Worker# for linux ppc64le platform 38*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-ppcle_64.exe' | wc -l)" != '0' ]] 39*e07d83d3SAndroid Build Coastguard Worker 40*e07d83d3SAndroid Build Coastguard Worker# for linux s390x platform 41*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-s390_64.exe' | wc -l)" != '0' ]] 42*e07d83d3SAndroid Build Coastguard Worker 43*e07d83d3SAndroid Build Coastguard Worker# from macos job: 44*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe' | wc -l)" != '0' ]] 45*e07d83d3SAndroid Build Coastguard Worker# copy all x86 artifacts to aarch until native artifacts are built 46*e07d83d3SAndroid Build Coastguard Workerfind "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe*' -exec bash -c 'cp "${0}" "${0/x86/aarch}"' {} \; 47*e07d83d3SAndroid Build Coastguard Worker 48*e07d83d3SAndroid Build Coastguard Worker# from windows job: 49*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-windows-x86_64.exe' | wc -l)" != '0' ]] 50*e07d83d3SAndroid Build Coastguard Worker[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-windows-x86_32.exe' | wc -l)" != '0' ]] 51*e07d83d3SAndroid Build Coastguard Worker 52*e07d83d3SAndroid Build Coastguard Worker 53*e07d83d3SAndroid Build Coastguard Workermkdir -p ~/.config/ 54*e07d83d3SAndroid Build Coastguard Workergsutil cp gs://grpc-testing-secrets/sonatype_credentials/sonatype-upload ~/.config/sonatype-upload 55*e07d83d3SAndroid Build Coastguard Worker 56*e07d83d3SAndroid Build Coastguard Workermkdir -p ~/java_signing/ 57*e07d83d3SAndroid Build Coastguard Workergsutil cp -r gs://grpc-testing-secrets/java_signing/ ~/ 58*e07d83d3SAndroid Build Coastguard Workergpg --batch --import ~/java_signing/grpc-java-team-sonatype.asc 59*e07d83d3SAndroid Build Coastguard Worker 60*e07d83d3SAndroid Build Coastguard Workergsutil cat gs://grpc-testing-secrets/dockerhub_credentials/grpcpackages.password \ 61*e07d83d3SAndroid Build Coastguard Worker | docker login --username grpcpackages --password-stdin 62*e07d83d3SAndroid Build Coastguard Worker 63*e07d83d3SAndroid Build Coastguard Worker# gpg commands changed between v1 and v2 are different. 64*e07d83d3SAndroid Build Coastguard Workergpg --version 65*e07d83d3SAndroid Build Coastguard Worker 66*e07d83d3SAndroid Build Coastguard Worker# This is the version found on kokoro. 67*e07d83d3SAndroid Build Coastguard Workerif gpg --version | grep 'gpg (GnuPG) 1.'; then 68*e07d83d3SAndroid Build Coastguard Worker # This command was tested on 1.4.16 69*e07d83d3SAndroid Build Coastguard Worker find "$LOCAL_MVN_ARTIFACTS" -type f \ 70*e07d83d3SAndroid Build Coastguard Worker -not -name "maven-metadata.xml*" -not -name "*.sha*" -not -name "*.md5" -exec \ 71*e07d83d3SAndroid Build Coastguard Worker bash -c 'cat ~/java_signing/passphrase | gpg --batch --passphrase-fd 0 --detach-sign -a {}' \; 72*e07d83d3SAndroid Build Coastguard Workerfi 73*e07d83d3SAndroid Build Coastguard Worker 74*e07d83d3SAndroid Build Coastguard Worker# This is the version found on corp workstations. Maybe kokoro will be updated to gpg2 some day. 75*e07d83d3SAndroid Build Coastguard Workerif gpg --version | grep 'gpg (GnuPG) 2.'; then 76*e07d83d3SAndroid Build Coastguard Worker # This command was tested on 2.2.2 77*e07d83d3SAndroid Build Coastguard Worker find "$LOCAL_MVN_ARTIFACTS" -type f \ 78*e07d83d3SAndroid Build Coastguard Worker -not -name "maven-metadata.xml*" -not -name "*.sha*" -not -name "*.md5" -exec \ 79*e07d83d3SAndroid Build Coastguard Worker gpg --batch --passphrase-file ~/java_signing/passphrase --pinentry-mode loopback \ 80*e07d83d3SAndroid Build Coastguard Worker --detach-sign -a {} \; 81*e07d83d3SAndroid Build Coastguard Workerfi 82*e07d83d3SAndroid Build Coastguard Worker 83*e07d83d3SAndroid Build Coastguard Worker# Just the numbers; does not include leading 'v' 84*e07d83d3SAndroid Build Coastguard WorkerVERSION="$(cat $LOCAL_OTHER_ARTIFACTS/version)" 85*e07d83d3SAndroid Build Coastguard WorkerEXAMPLE_HOSTNAME_ID="$(cat "$LOCAL_OTHER_ARTIFACTS/example-hostname.id")" 86*e07d83d3SAndroid Build Coastguard Workerdocker load --input "$LOCAL_OTHER_ARTIFACTS/example-hostname.tar" 87*e07d83d3SAndroid Build Coastguard WorkerLATEST_VERSION="$((echo "v$VERSION"; git ls-remote -t --refs https://github.com/grpc/grpc-java.git | cut -f 2 | sed s#refs/tags/##) | sort -V | tail -n 1)" 88*e07d83d3SAndroid Build Coastguard Worker 89*e07d83d3SAndroid Build Coastguard Worker 90*e07d83d3SAndroid Build Coastguard WorkerSTAGING_REPO=a93898609ef848 91*e07d83d3SAndroid Build Coastguard Worker"$GRPC_JAVA_DIR"/buildscripts/sonatype-upload.sh "$STAGING_REPO" "$LOCAL_MVN_ARTIFACTS" 92*e07d83d3SAndroid Build Coastguard Worker 93*e07d83d3SAndroid Build Coastguard Workerdocker tag "$EXAMPLE_HOSTNAME_ID" "grpc/java-example-hostname:${VERSION}" 94*e07d83d3SAndroid Build Coastguard Workerdocker push "grpc/java-example-hostname:${VERSION}" 95*e07d83d3SAndroid Build Coastguard Workerif [[ "v$VERSION" = "$LATEST_VERSION" ]]; then 96*e07d83d3SAndroid Build Coastguard Worker docker tag "$EXAMPLE_HOSTNAME_ID" grpc/java-example-hostname:latest 97*e07d83d3SAndroid Build Coastguard Worker docker push grpc/java-example-hostname:latest 98*e07d83d3SAndroid Build Coastguard Workerfi 99