3535from packaging import version
3636
3737
38+ def run_until_successful (command , * args , ** kwargs ):
39+ while True :
40+ completed_process = subprocess .run (command , * args , ** kwargs )
41+ exit_code = completed_process .returncode
42+ if exit_code == 0 :
43+ # successful, so nothing more to do here.
44+ return completed_process
45+
46+ print (f"The command { command !r} failed with exit code { exit_code } ." )
47+ print ("Please try to correct the failure and then re-run." )
48+ click .confirm ("Try again?" , abort = True )
49+
50+
3851@click .group ()
3952def cli ():
4053 """An interactive script to walk through the parts of creating a release.
@@ -197,7 +210,7 @@ def prepare():
197210 f .write (parsed_synapse_ast .dumps ())
198211
199212 # Generate changelogs
200- subprocess . run ("python3 -m towncrier" , shell = True )
213+ run_until_successful ("python3 -m towncrier" , shell = True )
201214
202215 # Generate debian changelogs
203216 if parsed_new_version .pre is not None :
@@ -209,11 +222,11 @@ def prepare():
209222 else :
210223 debian_version = new_version
211224
212- subprocess . run (
225+ run_until_successful (
213226 f'dch -M -v { debian_version } "New synapse release { debian_version } ."' ,
214227 shell = True ,
215228 )
216- subprocess . run ('dch -M -r -D stable ""' , shell = True )
229+ run_until_successful ('dch -M -r -D stable ""' , shell = True )
217230
218231 # Show the user the changes and ask if they want to edit the change log.
219232 repo .git .add ("-u" )
@@ -224,7 +237,7 @@ def prepare():
224237
225238 # Commit the changes.
226239 repo .git .add ("-u" )
227- repo .git .commit (f "-m { new_version } " )
240+ repo .git .commit ("-m" , new_version )
228241
229242 # We give the option to bail here in case the user wants to make sure things
230243 # are OK before pushing.
@@ -239,6 +252,8 @@ def prepare():
239252 # Otherwise, push and open the changelog in the browser.
240253 repo .git .push ("-u" , repo .remote ().name , repo .active_branch .name )
241254
255+ print ("Opening the changelog in your browser..." )
256+ print ("Please ask others to give it a check." )
242257 click .launch (
243258 f"https://github.com/matrix-org/synapse/blob/{ repo .active_branch .name } /CHANGES.md"
244259 )
@@ -290,7 +305,19 @@ def tag(gh_token: Optional[str]):
290305
291306 # If no token was given, we bail here
292307 if not gh_token :
308+ print ("Launching the GitHub release page in your browser." )
309+ print ("Please correct the title and create a draft." )
310+ if current_version .is_prerelease :
311+ print ("As this is an RC, remember to mark it as a pre-release!" )
312+ print ("(by the way, this step can be automated by passing --gh-token," )
313+ print ("or one of the GH_TOKEN or GITHUB_TOKEN env vars.)" )
293314 click .launch (f"https://github.com/matrix-org/synapse/releases/edit/{ tag_name } " )
315+
316+ print ("Once done, you need to wait for the release assets to build." )
317+ if click .confirm ("Launch the release assets actions page?" , default = True ):
318+ click .launch (
319+ f"https://github.com/matrix-org/synapse/actions?query=branch%3A{ tag_name } "
320+ )
294321 return
295322
296323 # Create a new draft release
@@ -305,6 +332,7 @@ def tag(gh_token: Optional[str]):
305332 )
306333
307334 # Open the release and the actions where we are building the assets.
335+ print ("Launching the release page and the actions page." )
308336 click .launch (release .html_url )
309337 click .launch (
310338 f"https://github.com/matrix-org/synapse/actions?query=branch%3A{ tag_name } "
0 commit comments