diff --git a/changelog/64023.added.md b/changelog/64023.added.md new file mode 100644 index 000000000000..90af8c2e4b0d --- /dev/null +++ b/changelog/64023.added.md @@ -0,0 +1 @@ +Add --next-release argument to salt/version.py, which prints the next upcoming release. diff --git a/salt/version.py b/salt/version.py index 67719bd0201f..05a16d008862 100644 --- a/salt/version.py +++ b/salt/version.py @@ -1,6 +1,7 @@ """ Set up the version of Salt """ +import argparse import operator import os import platform @@ -921,5 +922,17 @@ def versions_report(include_salt_cloud=False, include_extensions=True): yield from info +def _parser(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--next-release", help="Return the next release", action="store_true" + ) + return parser.parse_args() + + if __name__ == "__main__": - print(__version__) + args = _parser() + if args.next_release: + print(__saltstack_version__.next_release()) + else: + print(__version__) diff --git a/tools/changelog.py b/tools/changelog.py index 8cb9dd3e7a5b..bd2b290a5c27 100644 --- a/tools/changelog.py +++ b/tools/changelog.py @@ -15,7 +15,6 @@ from jinja2 import Environment, FileSystemLoader from ptscripts import Context, command_group -import salt.version from tools.utils import REPO_ROOT, Version CHANGELOG_LIKE_RE = re.compile(r"([\d]+)\.([a-z]+)$") @@ -176,8 +175,11 @@ def _get_pkg_changelog_contents(ctx: Context, version: Version): return changes -def _get_salt_version(ctx): - ret = ctx.run("python3", "salt/version.py", capture=True, check=False) +def _get_salt_version(ctx, next_release=False): + args = [] + if next_release: + args.append("--next-release") + ret = ctx.run("python3", "salt/version.py", *args, capture=True, check=False) if ret.returncode: ctx.error(ret.stderr.decode()) ctx.exit(1) @@ -314,7 +316,7 @@ def update_release_notes( next_release: bool = False, ): if salt_version is None: - salt_version = _get_salt_version(ctx) + salt_version = _get_salt_version(ctx, next_release=next_release) changes = _get_changelog_contents(ctx, salt_version) changes = "\n".join(changes.split("\n")[2:]) if salt_version.local: @@ -330,14 +332,6 @@ def update_release_notes( release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format( version ) - if next_release and not release: - version = ".".join( - str(part) - for part in salt.version.SaltStackVersion(*version).next_release().info - ) - release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format( - version - ) template_release_path = ( release_notes_path.parent / "templates" / f"{version}.md.template"