@@ -67,13 +67,24 @@ jobs:
6767 if versions_element is not None:
6868 for version_elem in versions_element.findall('version'):
6969 v = version_elem.text
70- if v and not any(suffix in v for suffix in ['SNAPSHOT', 'RC', 'BUILD']):
71- versions.append(v)
70+ if v and not any(suffix in v for suffix in ['SNAPSHOT', 'RC', 'BUILD', 'RELEASE']):
71+ # Only include versions that start with a digit and use standard format
72+ if v and v[0].isdigit() and v.count('.') >= 2:
73+ versions.append(v)
7274
7375 if versions:
7476 print(f"Found {len(versions)} versions via XML")
7577 print(f"Sample versions: {versions[-10:] if len(versions) > 10 else versions}")
76- return sorted(versions, key=version.parse)
78+ # Filter out any versions that still can't be parsed
79+ valid_versions = []
80+ for v in versions:
81+ try:
82+ version.parse(v)
83+ valid_versions.append(v)
84+ except Exception as e:
85+ print(f"Skipping invalid version format: {v}")
86+ print(f"Filtered to {len(valid_versions)} valid versions")
87+ return sorted(valid_versions, key=version.parse)
7788
7889 # Fallback to search API
7990 print("Trying search API fallback...")
@@ -101,12 +112,22 @@ jobs:
101112 versions = []
102113 for doc in docs:
103114 version_field = doc.get('v') or doc.get('version')
104- if version_field and not any(suffix in version_field for suffix in ['SNAPSHOT', 'RC', 'BUILD']):
115+ if (version_field and
116+ not any(suffix in version_field for suffix in ['SNAPSHOT', 'RC', 'BUILD', 'RELEASE']) and
117+ version_field[0].isdigit() and version_field.count('.') >= 2):
105118 versions.append(version_field)
106119
107120 if versions:
108- print(f"Successfully fetched {len(versions)} versions via search API")
109- return sorted(versions, key=version.parse)
121+ # Filter out any versions that still can't be parsed
122+ valid_versions = []
123+ for v in versions:
124+ try:
125+ version.parse(v)
126+ valid_versions.append(v)
127+ except Exception as e:
128+ print(f"Skipping invalid version format: {v}")
129+ print(f"Successfully fetched {len(valid_versions)} valid versions via search API")
130+ return sorted(valid_versions, key=version.parse)
110131
111132 except Exception as e:
112133 print(f"Attempt {attempt + 1} failed: {e}")
0 commit comments