@@ -24,8 +24,25 @@ function banner() {
2424 SEPARATOR=Y
2525}
2626
27+ # Uses a shallow clone of "${REPO}" and tags at the specified "${COMMIT}"
28+ # The format of the commit is 0.0.0-YYYYMMDD-[8-char-SHA] by default, but can be overriden.
29+ # You must specify the "TOKEN" environment variable with your GH token in order to create the tag
30+ function tag_googleapis() {
31+ set -x
32+ GOOGLEAPIS=" $( mktemp -d) "
33+ if [[ -z " ${TOKEN} " ]]; then
34+ echo " Env var TOKEN must set to a valid GH token"
35+ exit 1
36+ fi
37+ git clone --depth 1 " https://${TOKEN} @github.com/${REPO} " ${GOOGLEAPIS}
38+ pushd " ${GOOGLEAPIS} "
39+ git tag " ${TAG} "
40+ git push --tags && MESSAGE=" Successfully tagged ${REPO} with ${TAG} "
41+ set +x
42+ }
43+
2744banner " Determining googleapis HEAD commit and tarball checksum"
28- REPO=" googleapis/googleapis"
45+ REPO=" ${REPO :- googleapis/ googleapis} "
2946BRANCH=" master"
3047if [[ -z " ${COMMIT} " ]]; then
3148 COMMIT=$( curl -fsSL -H " Accept: application/vnd.github.VERSION.sha" \
@@ -87,25 +104,49 @@ if git diff --quiet bazel/workspace0.bzl \
87104 exit 0
88105fi
89106
90- banner " Regenerating libraries"
91- # generate-libraries fails if it creates a diff, so ignore its status.
92- TRIGGER_TYPE=' pr' ci/cloudbuild/build.sh \
93- --docker --trigger=generate-libraries-pr || true
107+ # banner "Regenerating libraries"
108+ # # generate-libraries fails if it creates a diff, so ignore its status.
109+ # TRIGGER_TYPE='pr' ci/cloudbuild/build.sh \
110+ # --docker --trigger=generate-libraries-pr || true
111+ #
112+ # banner "Creating commits"
113+ # git commit -m"chore: update googleapis SHA circa ${COMMIT_DATE}" \
114+ # ${PIPERORIGIN_REVID:+-m "${PIPERORIGIN_REVID}"} \
115+ # bazel/workspace0.bzl cmake/GoogleapisConfig.cmake MODULE.bazel
116+ # if ! git diff --quiet external/googleapis/protodeps \
117+ # external/googleapis/protolists; then
118+ # git commit -m"Update the protodeps/protolists" \
119+ # external/googleapis/protodeps external/googleapis/protolists
120+ # fi
121+ # if ! git diff --quiet .; then
122+ # git commit -m"Regenerate libraries" .
123+ # fi
124+ #
125+ # banner "Showing git state"
126+ # git status --untracked-files=no
127+ # echo ""
128+ # git show-branch
129+ #
130+ banner " Creating tag in ${REPO} "
131+ TAG=" ${TAG:- 0.0.0-$(date +" %Y%m%d" )-${COMMIT: 0: 8} } "
132+ # tag_googleapis
133+
134+ banner " Confirming presence of generated googleapis module in bazel-central-registry"
135+ JSON=$( gh search prs --repo=bazelbuild/bazel-central-registry --state=open --match=title " Publish googleapis@${TAG} " --json=url,title --order=desc)
94136
95- banner " Creating commits"
96- git commit -m" chore: update googleapis SHA circa ${COMMIT_DATE} " \
97- ${PIPERORIGIN_REVID: +-m " ${PIPERORIGIN_REVID} " } \
98- bazel/workspace0.bzl cmake/GoogleapisConfig.cmake MODULE.bazel
99- if ! git diff --quiet external/googleapis/protodeps \
100- external/googleapis/protolists; then
101- git commit -m" Update the protodeps/protolists" \
102- external/googleapis/protodeps external/googleapis/protolists
103- fi
104- if ! git diff --quiet . ; then
105- git commit -m" Regenerate libraries" .
106- fi
137+ function filter_json() {
138+ set -x
139+ jq -r --arg tag " ${TAG} " ' .[] | select(.title | test(' \" ' $tag' \" ' ))' <<< $" {json}"
140+ }
107141
108- banner " Showing git state"
109- git status --untracked-files=no
110- echo " "
111- git show-branch
142+ while true ; do
143+ FILTERED_JSON=$( filter_json)
144+ if -n " ${FILTERED_JSON} " ; then
145+ URL=$( jq ' .url' <<< " ${FILTERED_JSON}" )
146+ echo
147+ banner " Found PR with new googleapis module in bazel-centra-registry: ${URL} "
148+ exit 0
149+ fi
150+ sleep 5
151+ printf ' .'
152+ done
0 commit comments