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

Commit

Permalink
Fixes to the release script
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Jun 23, 2021
1 parent 27c06a6 commit 0cbabb3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
1 change: 1 addition & 0 deletions changelog.d/10239.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes to the release script.
48 changes: 25 additions & 23 deletions scripts-dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ def run():
if current_version.pre:
# If the current version is an RC we don't need to bump any of the
# version numbers (other than the RC number).
base_version = "{}.{}.{}".format(
current_version.major,
current_version.minor,
current_version.micro,
)

if rc:
new_version = "{}.{}.{}rc{}".format(
current_version.major,
Expand All @@ -97,49 +91,57 @@ def run():
current_version.pre[1] + 1,
)
else:
new_version = base_version
new_version = "{}.{}.{}".format(
current_version.major,
current_version.minor,
current_version.micro,
)
else:
# If this is a new release cycle then we need to know if its a major
# version bump or a hotfix.
release_type = click.prompt(
"Release type",
type=click.Choice(("major", "hotfix")),
type=click.Choice(("minor", "patch")),
show_choices=True,
default="major",
default="minor",
)

if release_type == "major":
base_version = new_version = "{}.{}.{}".format(
current_version.major,
current_version.minor + 1,
0,
)
if release_type == "minor":
if rc:
new_version = "{}.{}.{}rc1".format(
current_version.major,
current_version.minor + 1,
0,
)

else:
new_version = "{}.{}.{}".format(
current_version.major,
current_version.minor + 1,
0,
)
else:
base_version = new_version = "{}.{}.{}".format(
current_version.major,
current_version.minor,
current_version.micro + 1,
)
if rc:
new_version = "{}.{}.{}rc1".format(
current_version.major,
current_version.minor,
current_version.micro + 1,
)
else:
new_version = "{}.{}.{}".format(
current_version.major,
current_version.minor,
current_version.micro + 1,
)

# Confirm the calculated version is OK.
if not click.confirm(f"Create new version: {new_version}?", default=True):
click.get_current_context().abort()

# Switch to the release branch.
release_branch_name = f"release-v{current_version.major}.{current_version.minor}"
parsed_new_version = version.parse(new_version)
release_branch_name = (
f"release-v{parsed_new_version.major}.{parsed_new_version.minor}"
)
release_branch = find_ref(repo, release_branch_name)
if release_branch:
if release_branch.is_remote():
Expand All @@ -153,7 +155,7 @@ def run():
# release type.
if current_version.is_prerelease:
default = release_branch_name
elif release_type == "major":
elif release_type == "minor":
default = "develop"
else:
default = "master"
Expand Down

0 comments on commit 0cbabb3

Please sign in to comment.