Skip to content

Commit 0fcdf10

Browse files
authored
Merge pull request #34586 from def-/pr-auto-cut-release-idempotent
auto-cut-release: Make idempotent to allow rerunning when part failed
2 parents 15fb6cd + 34ee5a5 commit 0fcdf10

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

misc/python/materialize/release/auto_cut_release.py

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,43 @@ def main():
2929
release_version = MzVersion.parse_mz(f"{args.release_version}.0-rc.1")
3030
next_version = MzVersion.parse_mz(f"{args.next_version}.0-dev.0")
3131

32-
if latest_version >= release_version:
33-
print(
34-
f"Latest version ({latest_version}) is greater than or equal to release version ({release_version}); nothing to do"
35-
)
36-
return 0
37-
3832
print("Pulling latest main...")
3933
spawn.runv(["git", "pull", remote, "main"])
4034

41-
print("Creating temporary release branch...")
42-
git.create_branch(f"release-{release_version}")
35+
if latest_version < release_version:
36+
print("Creating temporary release branch...")
37+
git.create_branch(f"release-{release_version}")
4338

44-
print(f"Bumping version to {release_version}...")
45-
spawn.runv([MZ_ROOT / "bin" / "bump-version", str(release_version)])
39+
print(f"Bumping version to {release_version}...")
40+
spawn.runv([MZ_ROOT / "bin" / "bump-version", str(release_version)])
4641

47-
print("Tagging release...")
48-
git.tag_annotated(str(release_version))
42+
print("Tagging release...")
43+
git.tag_annotated(str(release_version))
4944

50-
print(f"Pushing release tag ({release_version}) to {remote}...")
51-
spawn.runv(["git", "push", remote, str(release_version)])
45+
print(f"Pushing release tag ({release_version}) to {remote}...")
46+
spawn.runv(["git", "push", remote, str(release_version)])
47+
48+
else:
49+
print(
50+
f"Latest version ({latest_version}) is greater than or equal to release version ({release_version}); nothing to cut"
51+
)
5252

5353
print("Checking out main...")
5454
git.checkout("main")
5555

56-
print(f"Bumping version on main to {next_version}...")
57-
spawn.runv([MZ_ROOT / "bin" / "bump-version", str(next_version)])
56+
current_version = MzVersion.parse_cargo()
57+
58+
if current_version < next_version:
59+
print(f"Bumping version on main to {next_version}...")
60+
spawn.runv([MZ_ROOT / "bin" / "bump-version", str(next_version)])
5861

59-
# Create the release page in the docs for the next version after the one
60-
# that was just cut.
61-
print(f"Creating {args.next_version}.md in the docs...")
62-
next_version_doc_file = doc_file_path(args.next_version)
63-
if not next_version_doc_file.exists():
64-
next_version_doc_file.write_text(
65-
f"""---
62+
# Create the release page in the docs for the next version after the one
63+
# that was just cut.
64+
print(f"Creating {args.next_version}.md in the docs...")
65+
next_version_doc_file = doc_file_path(args.next_version)
66+
if not next_version_doc_file.exists():
67+
next_version_doc_file.write_text(
68+
f"""---
6669
title: Materialize {args.next_version}
6770
date: {args.next_date}
6871
released: false
@@ -72,13 +75,17 @@ def main():
7275
_build:
7376
render: never
7477
---
75-
"""
78+
"""
79+
)
80+
git.add_file(str(next_version_doc_file))
81+
git.commit_all_changed(f"release: create doc file for {args.next_version}")
82+
83+
print(f"Pushing to {remote}...")
84+
spawn.runv(["git", "push", remote, "main"])
85+
else:
86+
print(
87+
f"Next version ({next_version}) is greater than or equal to current main version ({current_version}); nothing to bump"
7688
)
77-
git.add_file(str(next_version_doc_file))
78-
git.commit_all_changed(f"release: create doc file for {args.next_version}")
79-
80-
print(f"Pushing to {remote}...")
81-
spawn.runv(["git", "push", remote, "main"])
8289

8390
return 0
8491

0 commit comments

Comments
 (0)