diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh index a0b95de6c0df..3f7f46c1c257 100755 --- a/.github/scripts/update_generation_config.sh +++ b/.github/scripts/update_generation_config.sh @@ -18,7 +18,17 @@ function get_latest_released_version() { group_id_url_path="$(sed 's|\.|/|g' <<< "${group_id}")" url="https://repo1.maven.org/maven2/${group_id_url_path}/${artifact_id}/maven-metadata.xml" xml_content=$(curl -s --fail "${url}") - latest=$(xmllint --xpath 'metadata/versioning/latest/text()' - <<< "${xml_content}") + + # 1. Extract all version tags + # 2. Strip the XML tags to leave just the version numbers + # 3. Filter for strictly numbers.numbers.numbers (e.g., 2.54.0) + # 4. Sort by version (V) and take the last one (tail -n 1) + latest=$(echo "${xml_content}" \ + | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' \ + | sed -E 's/<[^>]+>//g' \ + | sort -V \ + | tail -n 1) + if [[ -z "${latest}" ]]; then echo "The latest version of ${group_id}:${artifact_id} is empty." echo "The returned json from maven.org is invalid: ${json_content}" @@ -174,4 +184,4 @@ if [ -z "${pr_num}" ]; then else git push gh pr edit "${pr_num}" --title "${title}" --body "${title}" -fi \ No newline at end of file +fi