|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
| 3 | +import datetime |
3 | 4 | import json
|
4 | 5 | import os
|
5 | 6 | import pathlib
|
@@ -56,7 +57,8 @@ def update_package_json(relpath, newversion):
|
56 | 57 | json_data = json.loads(f.read())
|
57 | 58 | json_data["version"] = newversion
|
58 | 59 | with open(p, "w") as f:
|
59 |
| - f.write(json.dumps(json_data, sort_keys=True, indent=2)) |
| 60 | + json.dump(json_data, f, sort_keys=True, indent=2) |
| 61 | + f.write("\n") |
60 | 62 |
|
61 | 63 |
|
62 | 64 | def main():
|
@@ -90,22 +92,35 @@ def main():
|
90 | 92 | ffi_toml = read_toml_version("deltachat-ffi/Cargo.toml")
|
91 | 93 | assert core_toml == ffi_toml, (core_toml, ffi_toml)
|
92 | 94 |
|
| 95 | + today = datetime.date.today().isoformat() |
| 96 | + |
93 | 97 | if "alpha" not in newversion:
|
94 |
| - for line in open("CHANGELOG.md"): |
| 98 | + changelog_name = "CHANGELOG.md" |
| 99 | + changelog_tmpname = changelog_name + ".tmp" |
| 100 | + changelog_tmp = open(changelog_tmpname, "w") |
| 101 | + found = False |
| 102 | + for line in open(changelog_name): |
95 | 103 | ## 1.25.0
|
96 |
| - if line.startswith("## [") and line[4:].strip().startswith(newversion): |
97 |
| - break |
98 |
| - else: |
| 104 | + if line == f"## [{newversion}]\n": |
| 105 | + line = f"## [{newversion}] - {today}\n" |
| 106 | + found = True |
| 107 | + changelog_tmp.write(line) |
| 108 | + if not found: |
99 | 109 | raise SystemExit(
|
100 |
| - f"CHANGELOG.md contains no entry for version: {newversion}" |
| 110 | + f"{changelog_name} contains no entry for version: {newversion}" |
101 | 111 | )
|
| 112 | + changelog_tmp.close() |
| 113 | + os.rename(changelog_tmpname, changelog_name) |
102 | 114 |
|
103 | 115 | for toml_filename in toml_list:
|
104 | 116 | replace_toml_version(toml_filename, newversion)
|
105 | 117 |
|
106 | 118 | for json_filename in json_list:
|
107 | 119 | update_package_json(json_filename, newversion)
|
108 | 120 |
|
| 121 | + with open("release-date.in", "w") as f: |
| 122 | + f.write(today) |
| 123 | + |
109 | 124 | print("running cargo check")
|
110 | 125 | subprocess.call(["cargo", "check"])
|
111 | 126 |
|
|
0 commit comments