Skip to content

Commit 1baedfe

Browse files
authored
chore: update action version through shell script (#3397)
In this PR: - Update composite action version in `update_generation_config.sh` so that the action version is updated in the same PR with image update. - Do not update the action version through renovate.
1 parent 254e9ff commit 1baedfe

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

hermetic_build/library_generation/owlbot/templates/java_library/.github/scripts/update_generation_config.sh

+32-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,23 @@ function update_config() {
2828
sed -i -e "s/^${key_word}.*$/${key_word}: ${new_value}/" "${file}"
2929
}
3030

31+
# Update an action to a new version in GitHub action.
32+
function update_action() {
33+
local key_word=$1
34+
local new_value=$2
35+
local file=$3
36+
echo "Update ${key_word} to ${new_value} in ${file}"
37+
# use a different delimiter because the key_word contains "/".
38+
sed -i -e "s|${key_word}@v.*$|${key_word}@v${new_value}|" "${file}"
39+
}
40+
3141
# The parameters of this script is:
3242
# 1. base_branch, the base branch of the result pull request.
3343
# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java
3444
# 3. [optional] generation_config, the path to the generation configuration,
3545
# the default value is generation_config.yaml in the repository root.
46+
# 4. [optional] workflow, the library generation workflow file,
47+
# the default value is .github/workflows/hermetic_library_generation.yaml.
3648
while [[ $# -gt 0 ]]; do
3749
key="$1"
3850
case "${key}" in
@@ -48,6 +60,10 @@ case "${key}" in
4860
generation_config="$2"
4961
shift
5062
;;
63+
--workflow)
64+
workflow="$2"
65+
shift
66+
;;
5167
*)
5268
echo "Invalid option: [$1]"
5369
exit 1
@@ -71,12 +87,17 @@ if [ -z "${generation_config}" ]; then
7187
echo "Use default generation config: ${generation_config}"
7288
fi
7389

90+
if [ -z "${workflow}" ]; then
91+
workflow=".github/workflows/hermetic_library_generation.yaml"
92+
echo "Use default library generation workflow file: ${workflow}"
93+
fi
94+
7495
current_branch="generate-libraries-${base_branch}"
7596
title="chore: Update generation configuration at $(date)"
7697

77-
# try to find a open pull request associated with the branch
98+
# Try to find a open pull request associated with the branch
7899
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
100+
# Create a branch if there's no open pull request associated with the
80101
# branch; otherwise checkout the pull request.
81102
if [ -z "${pr_num}" ]; then
82103
git checkout -b "${current_branch}"
@@ -85,7 +106,7 @@ else
85106
fi
86107

87108
mkdir tmp-googleapis
88-
# use partial clone because only commit history is needed.
109+
# Use partial clone because only commit history is needed.
89110
git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis
90111
pushd tmp-googleapis
91112
git pull
@@ -94,15 +115,20 @@ popd
94115
rm -rf tmp-googleapis
95116
update_config "googleapis_commitish" "${latest_commit}" "${generation_config}"
96117

97-
# update gapic-generator-java version to the latest
118+
# Update gapic-generator-java version to the latest
98119
latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java")
99120
update_config "gapic_generator_version" "${latest_version}" "${generation_config}"
100121

101-
# update libraries-bom version to the latest
122+
# Update composite action version to latest gapic-generator-java version
123+
update_action "googleapis/sdk-platform-java/.github/scripts" \
124+
"${latest_version}" \
125+
"${workflow}"
126+
127+
# Update libraries-bom version to the latest
102128
latest_version=$(get_latest_released_version "com.google.cloud" "libraries-bom")
103129
update_config "libraries_bom_version" "${latest_version}" "${generation_config}"
104130

105-
git add "${generation_config}"
131+
git add "${generation_config}" "${workflow}"
106132
changed_files=$(git diff --cached --name-only)
107133
if [[ "${changed_files}" == "" ]]; then
108134
echo "The latest generation config is not changed."

hermetic_build/library_generation/owlbot/templates/java_library/renovate.json

-17
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@
4444
],
4545
"depNameTemplate": "com.google.cloud:sdk-platform-java-config",
4646
"datasourceTemplate": "maven"
47-
},
48-
{
49-
"fileMatch": [
50-
"^.github/workflows/hermetic_library_generation.yaml$"
51-
],
52-
"matchStrings": [
53-
"uses: googleapis/sdk-platform-java/.github/scripts@v(?<currentValue>.+?)\\n"
54-
],
55-
"depNameTemplate": "com.google.api:gapic-generator-java",
56-
"datasourceTemplate": "maven"
5747
}
5848
],
5949
"packageRules": [
@@ -114,13 +104,6 @@
114104
"^com.fasterxml.jackson.core"
115105
],
116106
"groupName": "jackson dependencies"
117-
},
118-
{
119-
"matchPackagePatterns": [
120-
"^com.google.api:gapic-generator-java",
121-
"^com.google.cloud:sdk-platform-java-config"
122-
],
123-
"groupName": "SDK platform Java dependencies"
124107
}
125108
],
126109
"semanticCommits": true,

0 commit comments

Comments
 (0)