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): restore the version files when a guard fails
velixioee5ac6444c80
diff --git a/scripts/release.py b/scripts/release.pyindex 8cdd0fa18..847620a30 100644--- a/scripts/release.py+++ b/scripts/release.py@@ -31,6 +31,9 @@ GUARD_TESTS = ["tests/test_voicestudio_branding.py","tests/test_changelog_style.py",]+RELEASE_FILES = [+ "package.json", "pyproject.toml", "backend/core/version.py", "uv.lock", "CHANGELOG.md",+]SIGNING_SECRETS = ("ELECTRON_MACOS_CSC_LINK", "ELECTRON_WINDOWS_CSC_LINK", "APPLE_ID")_VERSION = re.compile(r"(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?")@@ -219,15 +222,23 @@ Release planraise SystemExit("Cancelled.")ensure_main()- bump_files(ROOT, version)- changelog = ROOT / "CHANGELOG.md"- changelog.write_text(- prepare_changelog(changelog.read_text(encoding="utf-8"), version, datetime.date.today()),- encoding="utf-8",- )- sh("uv", "lock")- sh("uv", "run", "pytest", *GUARD_TESTS, "-q")- sh("git", "add", "package.json", "pyproject.toml", "backend/core/version.py", "uv.lock", "CHANGELOG.md")+ try:+ bump_files(ROOT, version)+ changelog = ROOT / "CHANGELOG.md"+ changelog.write_text(+ prepare_changelog(changelog.read_text(encoding="utf-8"), version, datetime.date.today()),+ encoding="utf-8",+ )+ sh("uv", "lock")+ sh("uv", "run", "pytest", *GUARD_TESTS, "-q")+ except (subprocess.CalledProcessError, ValueError) as error:+ # Nothing is committed or pushed yet: put the working tree back.+ sh("git", "checkout", "--", *RELEASE_FILES)+ raise SystemExit(+ f"\nRelease aborted before committing: {error}\n"+ "The version files, uv.lock and CHANGELOG.md were restored; nothing was pushed."+ )+ sh("git", "add", *RELEASE_FILES)sh("git", "commit", "-m", f"chore(release): {tag}")sh("git", "push", "origin", "main")sh("git", "tag", tag)diff --git a/tests/test_release_script.py b/tests/test_release_script.pyindex 441f769fe..190633920 100644--- a/tests/test_release_script.py+++ b/tests/test_release_script.py@@ -113,11 +113,11 @@ 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=(), branch="main"):+def _drive(release, monkeypatch, answers, *, dry_run, secrets_missing=(), branch="main", fail_on=None, calls=None):"""Run release() with scripted prompts and every side effect recorded, not run."""import argparse- calls = []+ calls = [] if calls is None else callsfeed = iter(answers)def fake_sh(*cmd, **kw):@@ -130,6 +130,10 @@ def _drive(release, monkeypatch, answers, *, dry_run, secrets_missing=(), branchif cmd[:2] == ("git", "rev-list"):return "34"calls.append(cmd)+ if fail_on and fail_on in cmd:+ import subprocess++ raise subprocess.CalledProcessError(1, cmd)return ""monkeypatch.setattr("builtins.input", lambda prompt="": next(feed))@@ -185,3 +189,13 @@ def test_publish_without_signing_is_refused_unless_unsigned_is_accepted(release,calls = _drive(release, monkeypatch, ["stable", "", "publish", "y", tag], dry_run=False,secrets_missing=["APPLE_ID"])assert ("dispatch", tag, True) in calls++[email protected]("failing", ["pytest", "lock"])+def test_a_failed_guard_restores_the_files_and_pushes_nothing(release, monkeypatch, failing):+ calls = []+ with pytest.raises(SystemExit, match="restored; nothing was pushed"):+ _drive(release, monkeypatch, ["beta", "", "draft", "v0.5.7-beta.1"],+ dry_run=False, fail_on=failing, calls=calls)+ assert ("git", "checkout", "--", *release.RELEASE_FILES) in calls+ assert not any(c[:2] in (("git", "commit"), ("git", "push"), ("git", "tag")) for c in calls)