@@ -13,11 +13,6 @@ def get_remote_commit_sha(repo_url: str, branch: str) -> str:
1313 return output .split ("\t " )[0 ]
1414
1515
16- def _version_key (tag : str ) -> tuple [int , ...]:
17- version = tag .lstrip ("v" )
18- return tuple (map (int , version .split ("." )))
19-
20-
2116def get_remote_latest_tag (repo_url : str , tag_pattern : str ) -> str :
2217 output = subprocess .check_output (
2318 ["git" , "ls-remote" , "--tags" , repo_url ], text = True
@@ -33,15 +28,18 @@ def get_remote_latest_tag(repo_url: str, tag_pattern: str) -> str:
3328 if re .match (tag_pattern + "$" , tag ):
3429 tags .append (tag )
3530
36- return sorted (tags , key = _version_key )[- 1 ]
31+ def version_key (tag : str ) -> tuple [int , ...]:
32+ version = tag .lstrip ("v" )
33+ return tuple (map (int , version .split ("." )))
34+
35+ return sorted (tags , key = version_key )[- 1 ]
3736
3837
39- def get_current_version_from_file (file_path : str , pattern : str ) -> str :
38+ def get_current_versions_from_file (file_path : str , pattern : str ) -> list [ str ] :
4039 with open (file_path ) as f :
4140 content = f .read ()
4241
43- matches = re .findall (pattern , content )
44- return min (matches , key = _version_key )
42+ return re .findall (pattern , content )
4543
4644
4745def update_file_version (
@@ -149,22 +147,23 @@ def main() -> int:
149147
150148 args = parser .parse_args ()
151149
152- current_version = get_current_version_from_file (
153- args .file_path , args .current_version_pattern
154- )
155-
156150 if args .tag :
157151 latest_version = get_remote_latest_tag (args .repo_url , args .tag_pattern )
158152 else :
159153 latest_version = get_remote_commit_sha (args .repo_url , args .branch )
160154
161- if current_version == latest_version :
162- print (f"{ args .name } : No update needed (current: { current_version } )" )
155+ current_versions = get_current_versions_from_file (
156+ args .file_path , args .current_version_pattern
157+ )
158+
159+ if all (v == latest_version for v in current_versions ):
160+ print (f"{ args .name } : No update needed (current: { latest_version } )" )
163161 if not args .commit_message_fd :
164162 with open (os .environ ["GITHUB_OUTPUT" ], "a" ) as f :
165163 f .write ("HAS_UPDATES=false\n " )
166164 return 0
167165
166+ current_version = next (v for v in current_versions if v != latest_version )
168167 print (
169168 f"{ args .name } : Update available "
170169 f"({ current_version } -> { latest_version } )"
0 commit comments