@@ -162,18 +162,26 @@ def commit_modified_csprojs(csproj_paths, issue_number):
162162
163163
164164def push_new_version_tag ():
165+ subprocess .run (["git" , "fetch" , "--tags" ], check = True )
165166 tags_output = (
166- subprocess .check_output (["git" , "tag" , "--sort=-creatordate " ])
167+ subprocess .check_output (["git" , "tag" , "--sort=-v:refname " ])
167168 .decode ("utf-8" )
168169 .strip ()
169170 )
170171 if not tags_output :
171172 print ("No tags found in the repository." )
172173 return
173- latest = tags_output .splitlines ()[0 ].lstrip ("v" )
174- major , minor , build = map (int , latest .split ("." ))
174+ major = minor = build = None
175+ for line in tags_output .splitlines ():
176+ parts = line .lstrip ("v" ).split ("." )
177+ if len (parts ) == 3 and all (p .isdigit () for p in parts ):
178+ major , minor , build = map (int , parts )
179+ break
180+ if major is None :
181+ print ("No semver-formatted tags found." )
182+ return
175183 new_tag = f"v{ major } .{ minor } .{ build + 1 } "
176- print (f"Current Git Version: { latest } . Creating new tag { new_tag } ." )
184+ print (f"Highest tag: v { major } . { minor } . { build } . Creating new tag { new_tag } ." )
177185 subprocess .run (["git" , "tag" , new_tag ], check = True )
178186 subprocess .run (["git" , "push" , "--tags" ], check = True )
179187 subprocess .run (["git" , "push" ], check = True )
0 commit comments