Skip to content

Commit 52a848f

Browse files
committed
chore: pimp release script
1 parent bd9aa1d commit 52a848f

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

bin/release.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import subprocess
44

55

6-
def run_command(command: list[str], error_message: str) -> None:
6+
def run_command(command: list[str], error_message: str, success_message: str) -> None:
77
try:
88
subprocess.run(command, check=True, capture_output=True, text=True)
9+
print(success_message)
910
except subprocess.CalledProcessError as e:
1011
print(f"{error_message}: {e.stderr}")
1112
sys.exit(1)
@@ -20,13 +21,14 @@ def ensure_git_is_clean() -> None:
2021
"Error: Git working directory is not clean. Commit or stash changes first."
2122
)
2223
sys.exit(1)
24+
print("✅ Git working directory is clean")
2325

2426

2527
def update_version(new_version: str) -> None:
2628
cmd = f"sed -i 's/^version = .*/version = \"{new_version}\"/' pyproject.toml"
2729
try:
2830
subprocess.run(cmd, shell=True, check=True)
29-
print("Version updated")
31+
print("Version updated")
3032
except subprocess.CalledProcessError as e:
3133
print(f"Error updating version: {e}")
3234
sys.exit(1)
@@ -42,23 +44,42 @@ def release():
4244

4345
ensure_git_is_clean()
4446
update_version(new_version)
47+
4548
run_command(
4649
["uv", "lock", "--upgrade-package", "mediathequeroubaix"],
4750
"Error locking package",
51+
"✅ Locked dependencies in uv.lock",
52+
)
53+
run_command(
54+
["git", "add", "pyproject.toml", "uv.lock"],
55+
"Error adding changes",
56+
"✅ Updated pyproject.toml and uv.lock",
4857
)
49-
run_command(["git", "add", "pyproject.toml", "uv.lock"], "Error adding changes")
5058
run_command(
5159
["git", "commit", "--no-verify", "-m", f"chore: bump version to {new_version}"],
5260
"Error committing version change",
61+
"✅ Committed version change",
5362
)
5463
run_command(
5564
["git", "tag", "-a", new_version, "-m", f"Release {new_version}"],
5665
"Error creating git tag",
66+
f"✅ Created git tag: {new_version}",
67+
)
68+
run_command(
69+
["git", "push", "--tags"],
70+
"Error pushing",
71+
"✅ Pushed changes and tags to remote",
72+
)
73+
run_command(
74+
["uv", "build"],
75+
"Error building package",
76+
"✅ Built package",
77+
)
78+
run_command(
79+
["uv", "publish"],
80+
"Error publishing package",
81+
f"✅ Published package to PyPI version {new_version}",
5782
)
58-
run_command(["git", "push", "--tags"], "Error pushing")
59-
run_command(["uv", "build"], "Error building package")
60-
run_command(["uv", "publish"], "Error publishing package")
61-
print(f"✅ Released version: {new_version}")
6283

6384

6485
if __name__ == "__main__":

0 commit comments

Comments
 (0)