File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
174184else
175185 git push
176186 gh pr edit " ${pr_num} " --title " ${title} " --body " ${title} "
177- fi
187+ fi
You can’t perform that action at this time.
0 commit comments