Skip to content

Commit 20482e7

Browse files
committed
chore: update the release script
1 parent b9c6e60 commit 20482e7

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

scripts/release.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
def create_parser() -> argparse.ArgumentParser:
3535
"""Create the argument parser."""
3636
parser = argparse.ArgumentParser(description="make a release")
37-
parser.add_argument(
37+
mutex = parser.add_mutually_exclusive_group(required=True)
38+
mutex.add_argument(
39+
"--version",
40+
help="set the version",
41+
)
42+
mutex.add_argument(
3843
"--bump",
39-
required=True,
4044
help="update the version using the given semantics",
4145
)
4246
parser.add_argument(
@@ -57,20 +61,18 @@ def check_repository() -> None:
5761
raise SystemExit(1) from None
5862

5963

60-
def bump_version(bump: str) -> str:
61-
"""Bump the version and return the new version."""
64+
def update_version(version: str | None, bump: str | None) -> str:
65+
"""Update the version and return the new version."""
66+
args = ["uv", "version", "--no-sync", "--output-format", "json"]
67+
68+
if version:
69+
args.append(version)
70+
71+
if bump:
72+
args.extend(("--bump", bump))
73+
6274
try:
63-
version_json = subprocess.check_output(
64-
(
65-
"uv",
66-
"version",
67-
"--no-sync",
68-
"--output-format",
69-
"json",
70-
"--bump",
71-
bump,
72-
)
73-
)
75+
version_json = subprocess.check_output(args)
7476

7577
except subprocess.CalledProcessError:
7678
print_error("An error occurred while bumping the version.")
@@ -150,7 +152,7 @@ def main(argv: Sequence[str] | None = None) -> None:
150152

151153
check_repository()
152154

153-
version = bump_version(args.bump)
155+
version = update_version(args.version, args.bump)
154156

155157
release_branch = f"release/{version}"
156158

0 commit comments

Comments
 (0)