VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix(release): ask first, suggest from tags, switch to main for you
velixio78acca14d69a
diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex ec4f04e83..4aff3375d 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -162,9 +162,14 @@ branch. No Tauri build is maintained.## Release helper-`make release` (or `uv run python scripts/release.py`) runs a release from a clean, up-to-date-`main`. It asks **stable or beta**, suggests the next version, asks **draft or-publish**, prints the plan, and only proceeds when you type the tag name.+`make release` (or `uv run python scripts/release.py`) cuts a release from any+branch. It shows the last release and the version on `main`, then asks **stable+or beta** and suggests the new tag (`v0.5.7`, or `v0.5.7-beta.1`, `-beta.2`, ...+for a beta; the beta suffix is always `-beta.N`). If `package.json` already names+the upcoming release it uses that version; if that version is already tagged it+moves to the next patch. It then asks **draft or publish**, prints the plan+(including switching to `main` and fast-forwarding it), and only proceeds when you+type the tag name.- **Draft:** bumps the three version files in lockstep, runs `uv lock`, writesthe `CHANGELOG.md` section from `[Unreleased]` (a stable release renames it; adiff --git a/scripts/release.py b/scripts/release.pyindex bd04bc079..8cdd0fa18 100644--- a/scripts/release.py+++ b/scripts/release.py@@ -5,7 +5,8 @@uv run python scripts/release.py --dry-run # show the plan, change nothinguv run python scripts/release.py --publish TAG # publish an existing draft-Runs from a clean, up-to-date `main`. Bumps the three version files in lockstep,+Asks first (channel, version, draft/publish), shows the new tag next to the last+release, and only then switches to an up-to-date `main` if needed. Bumps the three version files in lockstep,refreshes uv.lock, writes the CHANGELOG section, runs the version guards,commits, pushes, tags, and either leaves the build as a draft (tag push) ordispatches `electron-release.yml` with `publish`. Nothing leaves the machine@@ -34,20 +35,36 @@ SIGNING_SECRETS = ("ELECTRON_MACOS_CSC_LINK", "ELECTRON_WINDOWS_CSC_LINK", "APPL_VERSION = re.compile(r"(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?")-def next_version(current: str, channel: str) -> str:- """Suggest the next version: beta -> beta.N+1 or next patch beta.1; stable -> final."""+def latest_stable(tags: list[str]) -> str | None:+ finals = [t for t in tags if re.fullmatch(r"v\d+\.\d+\.\d+", t)]+ return max(finals, key=lambda t: tuple(map(int, t[1:].split(".")))) if finals else None+++def next_version(current: str, channel: str, tags: list[str] = ()) -> str:+ """The version to release next.++ `current` is package.json on main, which usually already names the upcoming+ release; if that base is already tagged, move to the next patch. Beta numbers+ continue after any existing `vBASE-beta.N` tag: `0.5.7-beta.1`, `-beta.2`...+ """match = _VERSION.fullmatch(current)if not match:raise ValueError(f"Not a stable or beta version: {current}")- major, minor, patch, beta = (int(g) if g else None for g in match.groups())+ if channel not in ("stable", "beta"):+ raise ValueError(f"Unknown channel: {channel}")+ major, minor, patch = (int(g) for g in match.groups()[:3])+ taken = set(tags)+ if f"v{major}.{minor}.{patch}" in taken:+ patch += 1base = f"{major}.{minor}.{patch}"if channel == "stable":- return base if beta is not None else f"{major}.{minor}.{patch + 1}"- if channel != "beta":- raise ValueError(f"Unknown channel: {channel}")- if beta is not None:- return f"{base}-beta.{beta + 1}"- return f"{major}.{minor}.{patch + 1}-beta.1"+ return base+ numbers = [+ int(m.group(1))+ for t in taken+ if (m := re.fullmatch(rf"v{re.escape(base)}-beta\.(\d+)", t))+ ]+ return f"{base}-beta.{max(numbers, default=0) + 1}"def bump_files(root: Path, version: str) -> None:@@ -102,23 +119,28 @@ def ask(question: str, choices: list[str], default: str | None = None) -> str:print(f" Please answer one of: {', '.join(choices)}")-def preflight(tag: str | None = None) -> None:+def check_ready(tag: str | None = None) -> None:+ """Read-only checks for anything the helper cannot fix on its own."""problems = []- if sh("git", "branch", "--show-current", capture=True) != "main":- problems.append("not on main (releases are always cut from main)")if sh("git", "status", "--porcelain", "--untracked-files=no", capture=True):- problems.append("tracked files have uncommitted changes")- sh("git", "fetch", "-q", "origin", "main")- if sh("git", "rev-parse", "HEAD", capture=True) != sh("git", "rev-parse", "origin/main", capture=True):- problems.append("main is not identical to origin/main (pull or push first)")+ problems.append("tracked files have uncommitted changes (commit or stash them)")+ if sh("git", "rev-list", "--count", "origin/main..main", capture=True, check=False) not in ("", "0"):+ problems.append("local main has commits that are not on origin/main")if subprocess.run(["gh", "auth", "status"], cwd=ROOT, capture_output=True).returncode:- problems.append("gh is not authenticated")+ problems.append("gh is not authenticated (run: gh auth login)")if tag and sh("git", "ls-remote", "--tags", "origin", tag, capture=True):problems.append(f"tag {tag} already exists on origin")if problems:raise SystemExit("Cannot release:\n - " + "\n - ".join(problems))+def ensure_main() -> None:+ """Releases are cut from main: switch to it and fast-forward to origin/main."""+ if sh("git", "branch", "--show-current", capture=True) != "main":+ sh("git", "switch", "main")+ sh("git", "merge", "--ff-only", "origin/main")++def missing_signing_secrets() -> list[str]:result = subprocess.run(["gh", "secret", "list", "--json", "name", "--jq", ".[].name"],@@ -140,7 +162,8 @@ def dispatch_publish(tag: str, allow_unsigned: bool) -> None:def publish_existing(tag: str) -> None:channel = channel_for(tag.removeprefix("v"))- preflight()+ if subprocess.run(["gh", "auth", "status"], cwd=ROOT, capture_output=True).returncode:+ raise SystemExit("gh is not authenticated (run: gh auth login)")unsigned = Falseif missing_signing_secrets():unsigned = ask("Signing secrets missing or unreadable. Ship UNSIGNED installers?", ["y", "n"], "n") == "y"@@ -152,15 +175,24 @@ def publish_existing(tag: str) -> None:def release(args: argparse.Namespace) -> None:- current = json.loads((ROOT / "package.json").read_text(encoding="utf-8"))["version"]- preflight()+ sh("git", "fetch", "-q", "--tags", "origin", "main")+ current = json.loads(sh("git", "show", "origin/main:package.json", capture=True))["version"]+ tags = sh("git", "tag", "-l", "v*", capture=True).split()+ last = latest_stable(tags) or "none"+ branch = sh("git", "branch", "--show-current", capture=True)+ behind = sh("git", "rev-list", "--count", "main..origin/main", capture=True, check=False) or "?"+ check_ready()++ print(f"Last release: {last} package.json on main: {current}")channel = ask("Release channel?", ["stable", "beta"])- suggestion = next_version(current, channel)- version = input(f"Version [{suggestion}]: ").strip() or suggestion+ suggestion = next_version(current, channel, tags)+ shape = "X.Y.Z-beta.N, e.g. 0.5.7-beta.1" if channel == "beta" else "X.Y.Z"+ print(f" New release: v{suggestion} (last release {last}; format {shape})")+ version = input(f"Version [{suggestion}]: ").strip().removeprefix("v") or suggestionif channel_for(version) != channel:- raise SystemExit(f"{version} is not a {channel} version")+ raise SystemExit(f"{version} is not a {channel} version ({shape})")tag = f"v{version}"- preflight(tag)+ check_ready(tag)mode = ask("Draft (build only, publish later) or publish now?", ["draft", "publish"], "draft")unsigned = Falseif mode == "publish" and missing_signing_secrets():@@ -169,19 +201,24 @@ def release(args: argparse.Namespace) -> None:if not unsigned:raise SystemExit("Cancelled: configure signing, or choose draft.")+ switch = (+ f"switch from {branch} to main, " if branch != "main" else ""+ ) + (f"fast-forward main by {behind} commits, " if behind not in ("0", "?") else "")print(f"""Release planchannel {channel} ({'GitHub prerelease, never latest; :beta Docker' if channel == 'beta' else 'GitHub latest; :stable Docker'})- version {current} -> {version} tag {tag}+ new tag {tag} (last release {last})mode {mode}{' (UNSIGNED installers)' if unsigned else ''}- steps bump 3 version files + uv lock + CHANGELOG, run guards,- commit + push main, push tag{', then publish' if mode == 'publish' else ' (draft release; publish later with --publish)'}""")+ steps {switch}set package.json + pyproject.toml + backend/core/version.py to {version},+ uv lock, CHANGELOG section, run version guards,+ commit "chore(release): {tag}", push main, tag {tag}, push tag{', publish' if mode == 'publish' else ' (draft; publish later with --publish)'}""")if args.dry_run:print("\n--dry-run: nothing changed.")returnif input(f"\nThis pushes to main and tags. Type {tag} to confirm: ").strip() != tag:raise SystemExit("Cancelled.")+ ensure_main()bump_files(ROOT, version)changelog = ROOT / "CHANGELOG.md"changelog.write_text(@@ -204,7 +241,7 @@ Release plandispatch_publish(tag, unsigned)print(f"\nPublishing {tag}. Then verify: docs/RELEASING.md → Beta channel / verification table.")else:- print(f"\nDraft build started for {tag}. Publish later: uv run python scripts/release.py --publish {tag}")+ print(f"\nDraft build started for {tag}. Publish later: make release-publish TAG={tag}")def main() -> None:diff --git a/tests/test_release_script.py b/tests/test_release_script.pyindex 21ac26d89..441f769fe 100644--- a/tests/test_release_script.py+++ b/tests/test_release_script.py@@ -21,17 +21,28 @@ def release():@pytest.mark.parametrize(- ("current", "channel", "expected"),+ ("current", "channel", "tags", "expected"),[- ("0.5.7", "stable", "0.5.8"),- ("0.5.7", "beta", "0.5.8-beta.1"),- ("0.5.8-beta.1", "beta", "0.5.8-beta.2"),- ("0.5.8-beta.9", "beta", "0.5.8-beta.10"),- ("0.5.8-beta.2", "stable", "0.5.8"),+ # package.json already names the upcoming release: v0.5.7 is the new tag.+ ("0.5.7", "stable", ["v0.5.6"], "0.5.7"),+ ("0.5.7", "beta", ["v0.5.6"], "0.5.7-beta.1"),+ ("0.5.7", "beta", ["v0.5.6", "v0.5.7-beta.1"], "0.5.7-beta.2"),+ ("0.5.7", "beta", ["v0.5.7-beta.9"], "0.5.7-beta.10"),+ ("0.5.7-beta.2", "stable", ["v0.5.6", "v0.5.7-beta.2"], "0.5.7"),+ # the base is already released: move to the next patch+ ("0.5.7", "stable", ["v0.5.7"], "0.5.8"),+ ("0.5.7", "beta", ["v0.5.7"], "0.5.8-beta.1"),+ ("0.5.7", "stable", [], "0.5.7"),],)-def test_next_version(release, current, channel, expected):- assert release.next_version(current, channel) == expected+def test_next_version(release, current, channel, tags, expected):+ assert release.next_version(current, channel, tags) == expected+++def test_latest_stable_ignores_betas_and_sorts_numerically(release):+ tags = ["v0.5.9", "v0.5.10", "v0.5.11-beta.1", "v0.4.0", "nightly"]+ assert release.latest_stable(tags) == "v0.5.10"+ assert release.latest_stable(["v1.0.0-beta.1"]) is Nonedef test_next_version_rejects_other_shapes(release):@@ -102,34 +113,49 @@ def test_generated_changelog_passes_the_release_notes_extraction(release, versioassert section and section[1].strip()-def _drive(release, monkeypatch, answers, *, dry_run, secrets_missing=()):+def _drive(release, monkeypatch, answers, *, dry_run, secrets_missing=(), branch="main"):"""Run release() with scripted prompts and every side effect recorded, not run."""import argparsecalls = []feed = iter(answers)++ def fake_sh(*cmd, **kw):+ if cmd[:2] == ("git", "show"):+ return json.dumps({"version": "0.5.7"})+ if cmd[:3] == ("git", "tag", "-l"):+ return "v0.5.5 v0.5.6"+ if cmd[:2] == ("git", "branch"):+ return branch+ if cmd[:2] == ("git", "rev-list"):+ return "34"+ calls.append(cmd)+ return ""+monkeypatch.setattr("builtins.input", lambda prompt="": next(feed))- monkeypatch.setattr(release, "preflight", lambda tag=None: None)+ monkeypatch.setattr(release, "check_ready", lambda tag=None: None)+ monkeypatch.setattr(release, "ensure_main", lambda: calls.append(("ensure_main",)))monkeypatch.setattr(release, "missing_signing_secrets", lambda: list(secrets_missing))- monkeypatch.setattr(release, "sh", lambda *cmd, **kw: calls.append(cmd) or "")+ monkeypatch.setattr(release, "sh", fake_sh)monkeypatch.setattr(release, "bump_files", lambda *a: calls.append(("bump", *a[1:])))monkeypatch.setattr(release, "dispatch_publish", lambda *a: calls.append(("dispatch", *a)))monkeypatch.setattr(release.Path, "write_text", lambda self, *a, **k: calls.append(("write", self.name)))monkeypatch.setattr(release, "prepare_changelog", lambda text, *a: text)+ monkeypatch.setattr(release.Path, "read_text", lambda self, *a, **k: "")release.release(argparse.Namespace(dry_run=dry_run))return calls-def _current(release):- return json.loads((ROOT / "package.json").read_text())["version"]--def test_dry_run_shows_the_plan_and_changes_nothing(release, monkeypatch, capsys):- calls = _drive(release, monkeypatch, ["beta", "", "draft"], dry_run=True)- assert calls == []+ calls = _drive(release, monkeypatch, ["beta", "", "draft"], dry_run=True, branch="feat/x")+ assert [c for c in calls if c[:2] != ("git", "fetch")] == [] # a fetch is read-onlyout = capsys.readouterr().out+ assert "Last release: v0.5.6 package.json on main: 0.5.7" in out+ assert "New release: v0.5.7-beta.1" in out and "format X.Y.Z-beta.N" in out+ assert "new tag v0.5.7-beta.1 (last release v0.5.6)" in out+ assert "switch from feat/x to main, fast-forward main by 34 commits" in outassert "prerelease, never latest" in out and "nothing changed" in out@@ -144,14 +170,15 @@ def test_a_version_of_the_other_channel_is_refused(release, monkeypatch):def test_draft_pushes_the_tag_but_never_dispatches_a_publish(release, monkeypatch):- tag = f"v{release.next_version(_current(release), 'beta')}"+ tag = "v0.5.7-beta.1"calls = _drive(release, monkeypatch, ["beta", "", "draft", tag], dry_run=False)+ assert ("ensure_main",) in calls and ("bump", "0.5.7-beta.1") in callsassert ("git", "push", "origin", tag) in callsassert not any(c[0] == "dispatch" for c in calls)def test_publish_without_signing_is_refused_unless_unsigned_is_accepted(release, monkeypatch):- tag = f"v{release.next_version(_current(release), 'stable')}"+ tag = "v0.5.7"with pytest.raises(SystemExit, match="configure signing"):_drive(release, monkeypatch, ["stable", "", "publish", "n"], dry_run=False,secrets_missing=["APPLE_ID"])