Skip to content

Commit 1d00eaa

Browse files
authored
chore: Filter out non-semver versions in update_generation_config.sh (googleapis#11831)
Filter out non-semver versions in update_generation_config.sh. This is a temporary fix for this release because it is causing the [generation PR](googleapis#11822) on the main branch to get the RC version of gapic-generator-java and fail the compilation. The file is [templated](https://github.com/googleapis/sdk-platform-java/blob/main/hermetic_build/library_generation/owlbot/templates/java_library/.github/scripts/update_generation_config.sh) in sdk-platform-java. There will be another fix for the template in sdk-platform-java.
1 parent f32924a commit 1d00eaa

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/scripts/update_generation_config.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ function get_latest_released_version() {
1818
group_id_url_path="$(sed 's|\.|/|g' <<< "${group_id}")"
1919
url="https://repo1.maven.org/maven2/${group_id_url_path}/${artifact_id}/maven-metadata.xml"
2020
xml_content=$(curl -s --fail "${url}")
21-
latest=$(xmllint --xpath 'metadata/versioning/latest/text()' - <<< "${xml_content}")
21+
22+
# 1. Extract all version tags
23+
# 2. Strip the XML tags to leave just the version numbers
24+
# 3. Filter for strictly numbers.numbers.numbers (e.g., 2.54.0)
25+
# 4. Sort by version (V) and take the last one (tail -n 1)
26+
latest=$(echo "${xml_content}" \
27+
| grep -oE '<version>[0-9]+\.[0-9]+\.[0-9]+</version>' \
28+
| sed -E 's/<[^>]+>//g' \
29+
| sort -V \
30+
| tail -n 1)
31+
2232
if [[ -z "${latest}" ]]; then
2333
echo "The latest version of ${group_id}:${artifact_id} is empty."
2434
echo "The returned json from maven.org is invalid: ${json_content}"
@@ -174,4 +184,4 @@ if [ -z "${pr_num}" ]; then
174184
else
175185
git push
176186
gh pr edit "${pr_num}" --title "${title}" --body "${title}"
177-
fi
187+
fi

0 commit comments

Comments
 (0)