1#!/bin/bash 2 3# This script reads the last googleapis (https://github.com/googleapis/googleapis) 4# commit applied to the google-cloud-java repository. It then applies new GAPIC 5# library changes to the repository between the commit and the latest master of 6# the googleapis repository. (This script uses 7# create_commits_from_googleapis_commits.sh to generate the Git commits). 8# The caller of this script then can create a pull request to apply the changes 9# to google-cloud-java repository. 10# The location of google-cloud-java repository is specified by 11# GOOGLE_CLOUD_JAVA_DIR environment variable. 12 13set -ef 14 15BASEDIR=$(dirname "$0") 16 17if [ -z "${WORKSPACE}" ]; then 18 export WORKSPACE=$(mktemp -d -t workspace-XXXXX) 19fi 20 21if [ -z "${GOOGLE_CLOUD_JAVA_DIR}" ]; then 22 echo "GOOGLE_CLOUD_JAVA_DIR is not set" 23 exit 1 24fi 25 26export GOOGLEAPIS_DIR="${WORKSPACE}/googleapis" 27 28# TODO: It may be better to read the last googleapis's commit from the Git 29# commit messages. 30export GOOGLEAPIS_COMMIT_FILE=googleapis_commit.txt 31 32pushd "$WORKSPACE" 33 34BAZEL_VERSION=5.2.0 35BAZEL_DOWNLOAD_URL="https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64" 36curl "${BAZEL_DOWNLOAD_URL}" --output bazel 37chmod 755 bazel 38export PATH=$WORKSPACE:$PATH 39echo "$(date): Downloaded bazel: $(which bazel)" 40bazel version 41 42git clone --quiet --branch master https://github.com/googleapis/googleapis 43 44pushd "${GOOGLE_CLOUD_JAVA_DIR}" 45start_commit=$(cat "${GOOGLEAPIS_COMMIT_FILE}") 46 47if [ -z "${start_commit}" ]; then 48 echo "Couldn't read start_commit from ${GOOGLEAPIS_COMMIT_FILE}" 49 exit 1 50else 51 echo "$(date): start_commit: ${start_commit}" 52fi 53 54echo "$(date): Creating commits based on googleapis's ${start_commit} to origin/master" 55 56"${BASEDIR}/create_commits_from_googleapis_commits.sh" "${start_commit}" origin/master 57 58echo "$(date): Finished creating commits in ${GOOGLE_CLOUD_JAVA_DIR}" 59