@@ -215,6 +215,15 @@ class GitHub:
215215 f"/repos/{ self .repo } /releases/tags/{ tag_name } " )
216216 return self .json_request ("GET" , url )
217217
218+ def get_release_by_id (self , id : str ):
219+ url = (f"https://api.github.com/repos/{ self .repo } /releases/{ id } " )
220+ return self .json_request ("GET" , url )
221+
222+ def download_release_asset (self , url : str ):
223+ return self .request ("GET" , url , headers = {
224+ "Accept" : "application/octet-stream"
225+ })
226+
218227 def create_prerelease (self , tag_name : str , body : str ):
219228 url = f"https://api.github.com/repos/{ self .repo } /releases"
220229 return self .json_request ("POST" , url , body = {
@@ -451,7 +460,7 @@ class Distribution:
451460
452461 # Update release notes with checksums
453462 self .update_release_notes_with_checksums (
454- release , downloaded_paths , swift_version , swiftwasm_build_version )
463+ release , swift_version , swiftwasm_build_version )
455464
456465 if options .only_swift_sdk :
457466 return
@@ -692,15 +701,19 @@ You can install Swift SDKs for WebAssembly using the following commands:
692701 body += "```\n "
693702 return body
694703
695- def update_release_notes_with_checksums (self , release , downloaded_paths , swift_version , swiftwasm_build_version ):
704+ def update_release_notes_with_checksums (self , release , swift_version , swiftwasm_build_version ):
696705 checksums = []
697- for artifact , artifact_path in downloaded_paths :
698- if artifact ["name" ].endswith ("-artifactbundle" ):
699- name = os .path .basename (artifact_path )
700- checksum_path = artifact_path + ".sha256"
701- with open (checksum_path , "r" ) as f :
702- checksum = f .read ().strip ()
703- checksums .append ((name , artifact ["archive_download_url" ], checksum ))
706+ release = self .swift_github .get_release_by_id (release ["id" ])
707+ for artifact in release ["assets" ]:
708+ if not artifact ["name" ].endswith (".artifactbundle.zip" ):
709+ continue
710+ name = artifact ["name" ]
711+ artifact_download_url = artifact ["browser_download_url" ]
712+ checksum_download_url = artifact_download_url + ".sha256"
713+ checksum = self .github .download_release_asset (checksum_download_url )
714+ checksum = checksum .read ().decode ("utf-8" ).strip ()
715+ checksums .append ([name , artifact_download_url , checksum ])
716+
704717 body = self .make_release_note (swift_version , swiftwasm_build_version , checksums )
705718 self .swift_github .update_release_notes (release ["id" ], body )
706719
0 commit comments