Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a5444a5

Browse files
cloud-java-botJoeWang1127
andauthoredDec 17, 2024
chore: Update generation configuration at Sat Dec 14 02:27:56 UTC 2024 (#2443)
* chore: Update generation configuration at Wed Dec 4 02:29:45 UTC 2024 * chore: generate libraries at Wed Dec 4 02:30:21 UTC 2024 * chore: Update generation configuration at Thu Dec 5 02:29:53 UTC 2024 * chore: Update generation configuration at Fri Dec 6 02:29:21 UTC 2024 * chore: generate libraries at Fri Dec 6 02:29:58 UTC 2024 * chore: Update generation configuration at Sat Dec 7 02:28:39 UTC 2024 * chore: Update generation configuration at Tue Dec 10 02:30:19 UTC 2024 * chore: Update generation configuration at Wed Dec 11 02:29:32 UTC 2024 * chore: Update generation configuration at Thu Dec 12 02:29:28 UTC 2024 * chore: Update generation configuration at Fri Dec 13 02:29:53 UTC 2024 * chore: Update generation configuration at Sat Dec 14 02:27:56 UTC 2024 * update workflow script * update renovate --------- Co-authored-by: Joe Wang <joewa@google.com>
1 parent 825e717 commit a5444a5

File tree

4 files changed

+37
-56
lines changed

4 files changed

+37
-56
lines changed
 
+32-40
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
11
#!/bin/bash
2-
set -ex
2+
set -e
33
# This script should be run at the root of the repository.
4-
# This script is used to update googleapis_commitish, gapic_generator_version,
5-
# and libraries_bom_version in generation configuration at the time of running
6-
# and create a pull request.
4+
# This script is used to update googleapis commit to latest in generation
5+
# configuration at the time of running and create a pull request.
76

87
# The following commands need to be installed before running the script:
98
# 1. git
109
# 2. gh
11-
# 3. jq
12-
13-
# Utility functions
14-
# Get the latest released version of a Maven artifact.
15-
function get_latest_released_version() {
16-
local group_id=$1
17-
local artifact_id=$2
18-
latest=$(curl -s "https://search.maven.org/solrsearch/select?q=g:${group_id}+AND+a:${artifact_id}&core=gav&rows=500&wt=json" | jq -r '.response.docs[] | select(.v | test("^[0-9]+(\\.[0-9]+)*$")) | .v' | sort -V | tail -n 1)
19-
echo "${latest}"
20-
}
21-
22-
# Update a key to a new value in the generation config.
23-
function update_config() {
24-
local key_word=$1
25-
local new_value=$2
26-
local file=$3
27-
echo "Update ${key_word} to ${new_value} in ${file}"
28-
sed -i -e "s/^${key_word}.*$/${key_word}: ${new_value}/" "${file}"
29-
}
3010

3111
# The parameters of this script is:
3212
# 1. base_branch, the base branch of the result pull request.
@@ -72,50 +52,62 @@ if [ -z "${generation_config}" ]; then
7252
fi
7353

7454
current_branch="generate-libraries-${base_branch}"
75-
title="chore: Update generation configuration at $(date)"
55+
title="chore: update googleapis commit at $(date)"
7656

77-
# try to find a open pull request associated with the branch
57+
git checkout "${base_branch}"
58+
# Try to find a open pull request associated with the branch
7859
pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number")
79-
# create a branch if there's no open pull request associated with the
60+
# Create a branch if there's no open pull request associated with the
8061
# branch; otherwise checkout the pull request.
8162
if [ -z "${pr_num}" ]; then
8263
git checkout -b "${current_branch}"
64+
# Push the current branch to remote so that we can
65+
# compare the commits later.
66+
git push -u origin "${current_branch}"
8367
else
8468
gh pr checkout "${pr_num}"
8569
fi
8670

71+
# Only allow fast-forward merging; exit with non-zero result if there's merging
72+
# conflict.
73+
git merge -m "chore: merge ${base_branch} into ${current_branch}" "${base_branch}"
74+
8775
mkdir tmp-googleapis
88-
# use partial clone because only commit history is needed.
76+
# Use partial clone because only commit history is needed.
8977
git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis
9078
pushd tmp-googleapis
9179
git pull
9280
latest_commit=$(git rev-parse HEAD)
9381
popd
9482
rm -rf tmp-googleapis
95-
update_config "googleapis_commitish" "${latest_commit}" "${generation_config}"
96-
97-
# update gapic-generator-java version to the latest
98-
latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java")
99-
update_config "gapic_generator_version" "${latest_version}" "${generation_config}"
100-
101-
# update libraries-bom version to the latest
102-
latest_version=$(get_latest_released_version "com.google.cloud" "libraries-bom")
103-
update_config "libraries_bom_version" "${latest_version}" "${generation_config}"
83+
sed -i -e "s/^googleapis_commitish.*$/googleapis_commitish: ${latest_commit}/" "${generation_config}"
10484

10585
git add "${generation_config}"
10686
changed_files=$(git diff --cached --name-only)
10787
if [[ "${changed_files}" == "" ]]; then
108-
echo "The latest generation config is not changed."
88+
echo "The latest googleapis commit is not changed."
10989
echo "Skip committing to the pull request."
90+
else
91+
git commit -m "${title}"
92+
fi
93+
94+
# There are potentially at most two commits: merge commit and change commit.
95+
# We want to exit the script if no commit happens (otherwise this will be an
96+
# infinite loop).
97+
# `git cherry` is a way to find whether the local branch has commits that are
98+
# not in the remote branch.
99+
# If we find any such commit, push them to remote branch.
100+
unpushed_commit=$(git cherry -v "origin/${current_branch}" | wc -l)
101+
if [[ "${unpushed_commit}" -eq 0 ]]; then
102+
echo "No unpushed commits, exit"
110103
exit 0
111104
fi
112-
git commit -m "${title}"
105+
113106
if [ -z "${pr_num}" ]; then
114107
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git"
115-
git fetch -q --unshallow remote_repo
108+
git fetch -q remote_repo
116109
git push -f remote_repo "${current_branch}"
117110
gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}"
118111
else
119112
git push
120-
gh pr edit "${pr_num}" --title "${title}" --body "${title}"
121113
fi

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If you are using Maven without the BOM, add this to your dependencies:
4949
If you are using Gradle 5.x or later, add this to your dependencies:
5050

5151
```Groovy
52-
implementation platform('com.google.cloud:libraries-bom:26.50.0')
52+
implementation platform('com.google.cloud:libraries-bom:26.51.0')
5353
5454
implementation 'com.google.cloud:google-cloud-bigtable'
5555
```

‎generation_config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
gapic_generator_version: 2.50.0
2-
googleapis_commitish: 349841abac6c3e580ccce6e3d6fcc182ed2512c2
3-
libraries_bom_version: 26.50.0
1+
gapic_generator_version: 2.51.0
2+
googleapis_commitish: f4eff5440fd07389f820d22d2a55690c6390dc6d
3+
libraries_bom_version: 26.51.0
44
template_excludes:
55
- .gitignore
66
- .kokoro/presubmit/integration.cfg

‎renovate.json

+1-12
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@
7373
},
7474
{
7575
"packagePatterns": [
76-
"^com.google.api:gapic-generator-java",
7776
"^com.google.cloud:sdk-platform-java-config",
7877
"^com.google.cloud:gapic-libraries-bom"
7978
],
80-
"groupName": "sdk-platform-java dependencies"
79+
"groupName": "shared dependencies"
8180
}
8281
],
8382
"regexManagers": [
@@ -109,16 +108,6 @@
109108
"matchStrings": ["uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v(?<currentValue>.+?)\\n"],
110109
"depNameTemplate": "com.google.cloud:sdk-platform-java-config",
111110
"datasourceTemplate": "maven"
112-
},
113-
{
114-
"fileMatch": [
115-
".github/workflows/hermetic_library_generation.yaml"
116-
],
117-
"matchStrings": [
118-
"uses: googleapis/sdk-platform-java/.github/scripts@v(?<currentValue>.+?)\\n"
119-
],
120-
"depNameTemplate": "com.google.api:gapic-generator-java",
121-
"datasourceTemplate": "maven"
122111
}
123112
],
124113
"semanticCommits": true,

0 commit comments

Comments
 (0)
Failed to load comments.