Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def run(cmd: str, check: bool = True) -> str:
return result.stdout.decode().strip()


def release_branch(version: str) -> str:
return f"release-{version}"


def release_tag(version: str) -> str:
return version


def get_current_version() -> str:
out = run("bumpver show")
for line in out.splitlines():
Expand Down Expand Up @@ -35,15 +43,15 @@ def commit_bump(version: str) -> None:
def push_branch_and_tag(branch: str, version: str) -> None:
run(f"git push origin {branch}")

tag = f"v{version}"
tag = release_tag(version)
print(f"🏷️ Creating and pushing tag {tag}...")
run(f"git tag {tag}")
run(f"git push origin {tag}")


def push_tag_and_branch(version: str) -> str:
branch = f"release-v{version}"
tag = f"v{version}"
branch = release_branch(version)
tag = release_tag(version)

print(f"🌿 Creating branch {branch}...")
run(f"git checkout -b {branch}")
Expand All @@ -65,8 +73,8 @@ def push_tag_and_branch(version: str) -> str:
def create_pull_request(branch: str, version: str) -> None:
print(f"🔁 Creating pull request for {branch} → main...")
run(
f'gh pr create --title "Release v{version}" '
f'--body "This PR bumps the version to v{version} and tags the release." '
f'gh pr create --title "Release {version}" '
f'--body "This PR bumps the version to {version} and tags the release." '
f"--base main --head {branch}"
)

Expand Down Expand Up @@ -96,7 +104,7 @@ def open_release_draft(tag: str) -> None:
run("git pull origin main") # make sure it's up-to-date

version = bump_version(args.level)
branch = f"release-v{version}"
branch = release_branch(version)

create_branch(branch)
commit_bump(version)
Expand All @@ -106,6 +114,6 @@ def open_release_draft(tag: str) -> None:
create_pull_request(branch, version)

if not args.no_draft:
open_release_draft(f"v{version}")
open_release_draft(release_tag(version))

print(f"\n✅ Release flow completed for version {version}!")
Loading