@@ -108,10 +108,19 @@ def get_release_info(tag_name: str) -> Tuple[Optional[int], Optional[int]]:
108108 return None , None , None
109109
110110
111- def update_release_body (release_id : int , commit_sha : str , old_body : str ) -> bool :
111+ def update_release_body (release_id : int , commit_sha : str , old_body : str , sha : str , tag_name : str ) -> bool :
112112 try :
113113 url = f"{ base_url } /releases/{ release_id } "
114-
114+ ref_url = f"{ base_url } /git/refs/tags/{ tag_name } "
115+ data = {
116+ "sha" : commit_sha ,
117+ "force" : True
118+ }
119+ print (f"Updating tag { tag_name } to point to commit { commit_sha } " )
120+ response = requests .patch (ref_url , headers = headers , json = data )
121+ response .raise_for_status ()
122+ print (f"Successfully updated tag { tag_name } " )
123+
115124 sha_pattern = r'[a-fA-F0-9]{64}'
116125 new_body = old_body
117126
@@ -120,11 +129,10 @@ def update_release_body(release_id: int, commit_sha: str, old_body: str) -> bool
120129 old_sha = match .group ()
121130
122131 if old_sha != commit_sha :
123- new_body = new_body .replace (old_sha , commit_sha )
132+ new_body = new_body .replace (old_sha , sha )
124133 break
125134
126135 payload = {
127- "target_commitish" : commit_sha ,
128136 "body" : new_body
129137 }
130138
@@ -360,7 +368,7 @@ def main():
360368 filename , wheel_url = get_file_info_by_sha (sha )
361369 tag_name , release_title , version = generate_tag_and_title (filename )
362370 release_id , release_body , asset_id = get_release_info (tag_name )
363- update_release_body (release_id , commit_sha , release_body ) if release_id else None
371+ update_release_body (release_id , commit_sha , release_body , sha , tag_name ) if release_id else None
364372 update_release_asset (wheel_url , asset_id , release_id ) if release_id else None
365373
366374 print (f"Found { len (filenames )} files to process" )
0 commit comments