Skip to content

Commit 824008a

Browse files
authored
chore: Filter out non-semver versions in update_generation_config.sh (googleapis#4024)
Filter out non-semver versions in update_generation_config.sh. This is a follow up fix for googleapis/google-cloud-java#11831. The original logic caused the generation PR googleapis/google-cloud-java#11822 on the main branch to get the RC version of gapic-generator-java and fail the compilation.
1 parent a2b2179 commit 824008a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
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}"

0 commit comments

Comments
 (0)