Fixes to the release script (#10239)
* rename major/minor into the right semver terminology minor/patch (since this was something that got me very confused the first couple of times I've used the script) * name the release branch based on the new version, not the previous one
This commit is contained in:
parent
394673055d
commit
d731ed70d9
|
@ -0,0 +1 @@
|
||||||
|
Update the release script to use the semver terminology and determine the release branch based on the next version.
|
|
@ -83,12 +83,6 @@ def run():
|
||||||
if current_version.pre:
|
if current_version.pre:
|
||||||
# If the current version is an RC we don't need to bump any of the
|
# If the current version is an RC we don't need to bump any of the
|
||||||
# version numbers (other than the RC number).
|
# version numbers (other than the RC number).
|
||||||
base_version = "{}.{}.{}".format(
|
|
||||||
current_version.major,
|
|
||||||
current_version.minor,
|
|
||||||
current_version.micro,
|
|
||||||
)
|
|
||||||
|
|
||||||
if rc:
|
if rc:
|
||||||
new_version = "{}.{}.{}rc{}".format(
|
new_version = "{}.{}.{}rc{}".format(
|
||||||
current_version.major,
|
current_version.major,
|
||||||
|
@ -97,49 +91,57 @@ def run():
|
||||||
current_version.pre[1] + 1,
|
current_version.pre[1] + 1,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
new_version = base_version
|
new_version = "{}.{}.{}".format(
|
||||||
|
current_version.major,
|
||||||
|
current_version.minor,
|
||||||
|
current_version.micro,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# If this is a new release cycle then we need to know if its a major
|
# If this is a new release cycle then we need to know if it's a minor
|
||||||
# version bump or a hotfix.
|
# or a patch version bump.
|
||||||
release_type = click.prompt(
|
release_type = click.prompt(
|
||||||
"Release type",
|
"Release type",
|
||||||
type=click.Choice(("major", "hotfix")),
|
type=click.Choice(("minor", "patch")),
|
||||||
show_choices=True,
|
show_choices=True,
|
||||||
default="major",
|
default="minor",
|
||||||
)
|
)
|
||||||
|
|
||||||
if release_type == "major":
|
if release_type == "minor":
|
||||||
base_version = new_version = "{}.{}.{}".format(
|
|
||||||
current_version.major,
|
|
||||||
current_version.minor + 1,
|
|
||||||
0,
|
|
||||||
)
|
|
||||||
if rc:
|
if rc:
|
||||||
new_version = "{}.{}.{}rc1".format(
|
new_version = "{}.{}.{}rc1".format(
|
||||||
current_version.major,
|
current_version.major,
|
||||||
current_version.minor + 1,
|
current_version.minor + 1,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
new_version = "{}.{}.{}".format(
|
||||||
|
current_version.major,
|
||||||
|
current_version.minor + 1,
|
||||||
|
0,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
base_version = new_version = "{}.{}.{}".format(
|
|
||||||
current_version.major,
|
|
||||||
current_version.minor,
|
|
||||||
current_version.micro + 1,
|
|
||||||
)
|
|
||||||
if rc:
|
if rc:
|
||||||
new_version = "{}.{}.{}rc1".format(
|
new_version = "{}.{}.{}rc1".format(
|
||||||
current_version.major,
|
current_version.major,
|
||||||
current_version.minor,
|
current_version.minor,
|
||||||
current_version.micro + 1,
|
current_version.micro + 1,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
new_version = "{}.{}.{}".format(
|
||||||
|
current_version.major,
|
||||||
|
current_version.minor,
|
||||||
|
current_version.micro + 1,
|
||||||
|
)
|
||||||
|
|
||||||
# Confirm the calculated version is OK.
|
# Confirm the calculated version is OK.
|
||||||
if not click.confirm(f"Create new version: {new_version}?", default=True):
|
if not click.confirm(f"Create new version: {new_version}?", default=True):
|
||||||
click.get_current_context().abort()
|
click.get_current_context().abort()
|
||||||
|
|
||||||
# Switch to the release branch.
|
# 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)
|
release_branch = find_ref(repo, release_branch_name)
|
||||||
if release_branch:
|
if release_branch:
|
||||||
if release_branch.is_remote():
|
if release_branch.is_remote():
|
||||||
|
@ -153,7 +155,7 @@ def run():
|
||||||
# release type.
|
# release type.
|
||||||
if current_version.is_prerelease:
|
if current_version.is_prerelease:
|
||||||
default = release_branch_name
|
default = release_branch_name
|
||||||
elif release_type == "major":
|
elif release_type == "minor":
|
||||||
default = "develop"
|
default = "develop"
|
||||||
else:
|
else:
|
||||||
default = "master"
|
default = "master"
|
||||||
|
|
Loading…
Reference in New Issue