From f63c7d7d006b4ccb0f682ca794ae77628c1eadfc Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 1 Oct 2021 11:32:37 +0100 Subject: [PATCH 1/5] Give the opportunity to re-run towncrier or dch on failure --- scripts-dev/release.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts-dev/release.py b/scripts-dev/release.py index ab2d860ab8bd..43e584c4ca70 100755 --- a/scripts-dev/release.py +++ b/scripts-dev/release.py @@ -35,6 +35,19 @@ from packaging import version +def run_until_successful(command, *args, **kwargs): + while True: + completed_process = subprocess.run(command, *args, **kwargs) + exit_code = completed_process.returncode + if exit_code == 0: + # successful, so nothing more to do here. + return completed_process + + print(f"The command {command!r} failed with exit code {exit_code}.") + print("Please try to correct the failure and then re-run.") + click.confirm("Try again?", abort=True) + + @click.group() def cli(): """An interactive script to walk through the parts of creating a release. @@ -197,7 +210,7 @@ def prepare(): f.write(parsed_synapse_ast.dumps()) # Generate changelogs - subprocess.run("python3 -m towncrier", shell=True) + run_until_successful("python3 -m towncrier", shell=True) # Generate debian changelogs if parsed_new_version.pre is not None: @@ -209,11 +222,11 @@ def prepare(): else: debian_version = new_version - subprocess.run( + run_until_successful( f'dch -M -v {debian_version} "New synapse release {debian_version}."', shell=True, ) - subprocess.run('dch -M -r -D stable ""', shell=True) + run_until_successful('dch -M -r -D stable ""', shell=True) # Show the user the changes and ask if they want to edit the change log. repo.git.add("-u") From 134987884cdc34bd2c6ec52811ff523f504ac9c6 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 1 Oct 2021 11:33:14 +0100 Subject: [PATCH 2/5] Inform the user when a browser is being opened --- scripts-dev/release.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts-dev/release.py b/scripts-dev/release.py index 43e584c4ca70..f75836a9b5a8 100755 --- a/scripts-dev/release.py +++ b/scripts-dev/release.py @@ -252,6 +252,8 @@ def prepare(): # Otherwise, push and open the changelog in the browser. repo.git.push("-u", repo.remote().name, repo.active_branch.name) + print("Opening the changelog in your browser...") + print("Please ask others to give it a check.") click.launch( f"https://github.com/matrix-org/synapse/blob/{repo.active_branch.name}/CHANGES.md" ) @@ -303,7 +305,19 @@ def tag(gh_token: Optional[str]): # If no token was given, we bail here if not gh_token: + print("Launching the GitHub release page in your browser.") + print("Please correct the title and create a draft.") + if current_version.is_prerelease: + print("As this is an RC, remember to mark it as a pre-release!") + print("(by the way, this step can be automated by passing --gh-token,") + print(" or one of the GH_TOKEN or GITHUB_TOKEN env vars.)") click.launch(f"https://github.com/matrix-org/synapse/releases/edit/{tag_name}") + + print("Once done, you need to wait for the release assets to build.") + if click.confirm("Launch the release assets actions page?", default=True): + click.launch( + f"https://github.com/matrix-org/synapse/actions?query=branch%3A{tag_name}" + ) return # Create a new draft release @@ -318,6 +332,7 @@ def tag(gh_token: Optional[str]): ) # Open the release and the actions where we are building the assets. + print("Launching the release page and the actions page.") click.launch(release.html_url) click.launch( f"https://github.com/matrix-org/synapse/actions?query=branch%3A{tag_name}" From 62e2b29837bce486579bc15b89993a1524ffc54b Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 1 Oct 2021 14:02:39 +0100 Subject: [PATCH 3/5] Remove leading space from release script commit message --- scripts-dev/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-dev/release.py b/scripts-dev/release.py index f75836a9b5a8..781216d5efcf 100755 --- a/scripts-dev/release.py +++ b/scripts-dev/release.py @@ -237,7 +237,7 @@ def prepare(): # Commit the changes. repo.git.add("-u") - repo.git.commit(f"-m {new_version}") + repo.git.commit("-m", new_version) # We give the option to bail here in case the user wants to make sure things # are OK before pushing. From f7d1641cb03cd1c898a29e17e740efc1cef87170 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 1 Oct 2021 14:05:20 +0100 Subject: [PATCH 4/5] Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/10966.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/10966.misc diff --git a/changelog.d/10966.misc b/changelog.d/10966.misc new file mode 100644 index 000000000000..095b9d56897c --- /dev/null +++ b/changelog.d/10966.misc @@ -0,0 +1 @@ +Make the release script more robust and transparent. From 1158834aac194c24478ce9abc602fffa8c963a65 Mon Sep 17 00:00:00 2001 From: reivilibre Date: Thu, 7 Oct 2021 17:59:03 +0100 Subject: [PATCH 5/5] Update scripts-dev/release.py Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- scripts-dev/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-dev/release.py b/scripts-dev/release.py index 781216d5efcf..4e1f99fee4e1 100755 --- a/scripts-dev/release.py +++ b/scripts-dev/release.py @@ -310,7 +310,7 @@ def tag(gh_token: Optional[str]): if current_version.is_prerelease: print("As this is an RC, remember to mark it as a pre-release!") print("(by the way, this step can be automated by passing --gh-token,") - print(" or one of the GH_TOKEN or GITHUB_TOKEN env vars.)") + print("or one of the GH_TOKEN or GITHUB_TOKEN env vars.)") click.launch(f"https://github.com/matrix-org/synapse/releases/edit/{tag_name}") print("Once done, you need to wait for the release assets to build.")