Skip to content

Commit 2ccf220

Browse files
updates to bump script
1 parent 7662d02 commit 2ccf220

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

.bin/bump.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def get_new_version(version: Version, package: str | None = None) -> tuple[str,
110110

111111

112112
def get_next_calver() -> str:
113-
"""Generate next CalVer tag in YYYY.MM.INCR format."""
113+
"""Generate next CalVer tag in YYYY.M.INCR format."""
114114
today = date.today()
115-
prefix = today.strftime("%Y.%m")
115+
prefix = f"{today.year}.{today.month}" # No zero-padding
116116

117117
# Check CHANGELOG for existing CalVer tags from this month
118118
changelog_path = Path("CHANGELOG.md")
@@ -352,6 +352,15 @@ def bump(
352352
if not dry_run and not typer.confirm("\nProceed with these bumps?"):
353353
raise typer.Abort()
354354

355+
# Generate CalVer early to use in branch name
356+
calver_tag = get_next_calver() if changelog else ""
357+
358+
# Create release branch
359+
if calver_tag and not dry_run:
360+
branch_name = f"release-v{calver_tag}"
361+
console.print(f"\n[bold]Creating release branch:[/bold] {branch_name}")
362+
run(["git", "checkout", "-b", branch_name], dry_run=dry_run)
363+
355364
# Execute the bumps
356365
console.print("\n[bold]Executing version bumps...[/bold]")
357366
for pkg_name, _, _ in bumps_to_make:
@@ -364,10 +373,15 @@ def bump(
364373
)
365374

366375
# Update ancillary files
367-
calver_tag = ""
368376
if changelog:
369377
console.print("\n[bold]Updating CHANGELOG...[/bold]")
370-
calver_tag = update_changelog(bumps_to_make, dry_run)
378+
# Pass the already-generated calver_tag to update_changelog
379+
updated_calver = update_changelog(bumps_to_make, dry_run)
380+
# Verify it matches what we expected
381+
if updated_calver != calver_tag:
382+
console.print(
383+
f"[yellow]Warning: CalVer mismatch - expected {calver_tag}, got {updated_calver}[/yellow]"
384+
)
371385

372386
# Write VERSION file with CalVer
373387
if calver_tag:
@@ -444,9 +458,17 @@ def bump(
444458
if not dry_run:
445459
console.print("\n[dim]Next steps:[/dim]")
446460
console.print(" 1. Review the changes: [cyan]git diff HEAD~1[/cyan]")
447-
console.print(" 2. Push to remote: [cyan]git push[/cyan]")
448-
console.print(" 3. Create a PR or merge to main")
449-
console.print(" 4. Run release script: [cyan]./bin/release.py[/cyan]")
461+
if calver_tag:
462+
console.print(
463+
f" 2. Push the release branch: [cyan]git push -u origin release-v{calver_tag}[/cyan]"
464+
)
465+
console.print(" 3. Create a PR from the release branch to main")
466+
console.print(
467+
" 4. After PR is merged, run release script: [cyan].bin/release.py[/cyan]"
468+
)
469+
else:
470+
console.print(" 2. Push to remote: [cyan]git push[/cyan]")
471+
console.print(" 3. Create a PR or merge to main")
450472

451473

452474
if __name__ == "__main__":

0 commit comments

Comments
 (0)