Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Check we're on the right branch before tagging, and on the right tag before uploading #12556

Merged
merged 10 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12556.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Release script: confirm the commit to be tagged before tagging.
11 changes: 9 additions & 2 deletions scripts-dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def tag(gh_token: Optional[str]):
tag_name = f"v{current_version}"

# Check we haven't released this version.
if tag_name in repo.tags:
raise click.ClickException(f"Tag {tag_name} already exists!\n")
# if tag_name in repo.tags:
# raise click.ClickException(f"Tag {tag_name} already exists!\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intentional, or just part of you testing?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Just testing.


# Get the appropriate changelogs and tag.
changes = get_changes_for_version(current_version)
Expand All @@ -295,6 +295,13 @@ def tag(gh_token: Optional[str]):
if click.confirm("Edit text?", default=False):
changes = click.edit(changes, require_save=False)

commit = repo.head.commit
click.echo(
f"{repo.head.ref} {commit} {commit.summary!r}\n"
f"by {commit.author} <{commit.author.email}>, "
f"committed at {commit.committed_datetime}"
)
click.confirm(f"Tag this commit as {tag_name}?", default=False, abort=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to fail if we're not on the right branch, maybe? We already check the right branch in another command:

https://github.com/matrix-org/synapse/blob/706456de1f63a4b9796592fd452da7ce30735274/scripts-dev/release.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a line number for me, sorry? I think that link is missing one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bah, sorry, it got stripped, its:

release_branch_name = (
f"release-v{parsed_new_version.major}.{parsed_new_version.minor}"
)
release_branch = find_ref(repo, release_branch_name)

repo.create_tag(tag_name, message=changes, sign=True)

if not click.confirm("Push tag to GitHub?", default=True):
Expand Down