Skip to content

Commit 94b617b

Browse files
committed
🔨 Improve release script with lock file handling
Add UV lock file updating during release process - Add new update_lockfile() function to refresh uv.lock before release - Add type annotation to replace_version function for better typing - Update commit_and_push to include uv.lock in staged files - Integrate lockfile update into main release workflow This ensures the dependency lockfile is always updated with the correct package version during releases, improving consistency.
1 parent 8c4bd0f commit 94b617b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎scripts/release.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def update_docs_version(new_version: str) -> None:
309309
version_pattern = re.compile(r"^(version:\s*)([^\s]+)", re.MULTILINE)
310310

311311
# Use a lambda function for replacement to avoid the group reference issue
312-
def replace_version(match):
312+
def replace_version(match: re.Match[str]) -> str:
313313
return match.group(1) + new_version
314314

315315
updated_content = version_pattern.sub(replace_version, content)
@@ -324,6 +324,17 @@ def replace_version(match):
324324
print_success(f"Updated version in {DOCS_INDEX} to {new_version}")
325325

326326

327+
def update_lockfile() -> None:
328+
"""Update the uv.lock file to ensure it has the correct version of package."""
329+
print_step("Updating dependency lockfile")
330+
try:
331+
run_uv_command(["lock"], check=True)
332+
print_success("Updated uv.lock file")
333+
except subprocess.CalledProcessError as e:
334+
print_error(f"Failed to update lockfile: {e!s}")
335+
sys.exit(1)
336+
337+
327338
def show_changes() -> bool:
328339
"""Show changes and ask for confirmation."""
329340
print_warning("The following files will be modified:")
@@ -338,7 +349,7 @@ def commit_and_push(version: str) -> None:
338349
"""Commit and push changes to the repository."""
339350
print_step("Committing and pushing changes")
340351
try:
341-
run_git_command(["add", PYPROJECT_TOML, DOCS_INDEX], check=True)
352+
run_git_command(["add", PYPROJECT_TOML, DOCS_INDEX, "uv.lock"], check=True)
342353
run_git_command(["commit", "-m", f":rocket: Release version {version}"], check=True)
343354
run_git_command(["push"], check=True)
344355
run_git_command(["tag", f"v{version}"], check=True)
@@ -377,6 +388,7 @@ def main() -> None:
377388

378389
update_version(new_version)
379390
update_docs_version(new_version)
391+
update_lockfile()
380392

381393
if not show_changes():
382394
print_error("Release cancelled.")

0 commit comments

Comments
 (0)