|
12 | 12 | import os
|
13 | 13 | import sys
|
14 | 14 | from pathlib import Path
|
| 15 | +from datetime import datetime, timedelta |
15 | 16 |
|
16 | 17 | from materialize import MZ_ROOT, git, spawn
|
17 | 18 | from materialize.mz_version import MzVersion
|
18 | 19 |
|
| 20 | +version_file_text = """--- |
| 21 | +title: "Materialize $VERSION" |
| 22 | +date: $DATE |
| 23 | +released: false |
| 24 | +_build: |
| 25 | + render: never |
| 26 | +--- |
| 27 | +""" |
| 28 | + |
19 | 29 |
|
20 | 30 | def main():
|
21 | 31 | remote = git.get_remote()
|
22 | 32 | latest_version = git.get_latest_version(version_type=MzVersion)
|
23 | 33 | release_version = latest_version.bump_minor()
|
24 |
| - next_version = release_version.bump_minor().replace(prerelease="dev") |
| 34 | + next_version = MzVersion.parse_mz(f"{release_version.bump_minor()}-dev") |
25 | 35 |
|
26 | 36 | if os.getenv("CI"):
|
27 | 37 | print("Installing credentials for Ci...")
|
@@ -54,6 +64,19 @@ def main():
|
54 | 64 | print(f"Bumping version on main to {next_version}...")
|
55 | 65 | spawn.runv([MZ_ROOT / "bin" / "bump-version", str(next_version)])
|
56 | 66 |
|
| 67 | + next_version_final = str(next_version).removesuffix(".0-dev") |
| 68 | + print(f"Creating {next_version_final}.md in the docs") |
| 69 | + today = datetime.today() |
| 70 | + next_thursday = today + timedelta(days=((3 - today.weekday()) % 7 or 7)) |
| 71 | + next_version_doc_file = Path( |
| 72 | + MZ_ROOT / "doc" / "user" / "content" / "releases" / f"{next_version_final}.md" |
| 73 | + ) |
| 74 | + if not next_version_doc_file.exists(): |
| 75 | + text = version_file_text.replace("$VERSION", str(next_version_final)).replace( |
| 76 | + "$DATE", next_thursday.strftime("%Y-%m-%d") |
| 77 | + ) |
| 78 | + next_version_doc_file.write_text(text) |
| 79 | + |
57 | 80 | print(f"Pushing to {remote}...")
|
58 | 81 | spawn.runv(["git", "push", remote, "main"])
|
59 | 82 |
|
|
0 commit comments