@@ -58,9 +58,10 @@ impl GithubRelease {
5858 cmd. read ( )
5959 . map ( |s| s. trim ( ) . to_owned ( ) )
6060 . map_err ( |e| format ! ( "Failed to execute dispatch attach-artifacts.yml: {e}" ) )
61+ . and_then ( |output| Self :: run_id_from_output ( & output) . map ( str:: to_owned) )
6162 }
6263
63- fn run_id_from_output < ' a > ( & self , output : & ' a str ) -> Result < & ' a str , String > {
64+ fn run_id_from_output ( output : & str ) -> Result < & str , String > {
6465 let url = output
6566 . split_whitespace ( )
6667 . find ( |word| word. starts_with ( "https://" ) && word. contains ( "/actions/runs/" ) )
@@ -78,26 +79,16 @@ impl GithubRelease {
7879 } )
7980 }
8081
81- fn wait_for_artifacts ( & self , workflow_output : & str ) -> Result < ( ) , String > {
82- let run_id = self . run_id_from_output ( workflow_output) ?;
82+ fn wait_for_workflow ( & self , run_id : & str ) -> Result < ( ) , String > {
8383 let cmd = cmd ! ( "gh" , "run" , "watch" , run_id, "--repo" , REPO , "--exit-status" ) ;
8484 println ! ( "$> {:?}" , cmd) ;
8585 cmd. run ( )
8686 . map ( |_| ( ) )
87- . map_err ( |e| format ! ( "Failed to execute watch attach-artifacts.yml : {e}" ) )
87+ . map_err ( |e| format ! ( "Failed to execute watch workflow : {e}" ) )
8888 }
8989
9090 fn publish_release ( & self ) -> Result < ( ) , String > {
91- let release_endpoint = format ! ( "repos/{}/releases/tags/{}" , REPO , self . version) ;
92- let id_cmd = cmd ! ( "gh" , "api" , & release_endpoint, "--jq" , ".id" ) ;
93- println ! ( "$> {:?}" , id_cmd) ;
94- let release_id = id_cmd
95- . read ( )
96- . map ( |s| s. trim ( ) . to_owned ( ) )
97- . map_err ( |e| format ! ( "Failed to execute get GitHub release id: {e}" ) ) ?;
98-
99- let publish_endpoint = format ! ( "repos/{}/releases/{}" , REPO , release_id) ;
100- let publish_cmd = cmd ! ( "gh" , "api" , "--method" , "PATCH" , & publish_endpoint, "-F" , "draft=false" ) ;
91+ let publish_cmd = cmd ! ( "gh" , "release" , "edit" , & self . version, "--repo" , REPO , "--draft=false" ) ;
10192 println ! ( "$> {:?}" , publish_cmd) ;
10293 publish_cmd
10394 . run ( )
@@ -115,8 +106,8 @@ impl ReleaseTarget for GithubRelease {
115106 }
116107
117108 println ! ( "Found draft GitHub release {}: {}" , self . version, release. url) ;
118- let run_url = self . dispatch_attach_artifacts ( ) ?;
119- self . wait_for_artifacts ( & run_url ) ?;
109+ let run_id = self . dispatch_attach_artifacts ( ) ?;
110+ self . wait_for_workflow ( & run_id ) ?;
120111 self . publish_release ( ) ?;
121112 println ! ( "Published GitHub release {}." , self . version) ;
122113 Ok ( ( ) )
0 commit comments