Skip to content

Commit fa95b26

Browse files
committed
Backport new set_core_version.py
1 parent 0e9f8c4 commit fa95b26

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

scripts/set_core_version.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
import datetime
34
import json
45
import os
56
import pathlib
@@ -56,7 +57,8 @@ def update_package_json(relpath, newversion):
5657
json_data = json.loads(f.read())
5758
json_data["version"] = newversion
5859
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")
6062

6163

6264
def main():
@@ -90,22 +92,35 @@ def main():
9092
ffi_toml = read_toml_version("deltachat-ffi/Cargo.toml")
9193
assert core_toml == ffi_toml, (core_toml, ffi_toml)
9294

95+
today = datetime.date.today().isoformat()
96+
9397
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):
95103
## 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:
99109
raise SystemExit(
100-
f"CHANGELOG.md contains no entry for version: {newversion}"
110+
f"{changelog_name} contains no entry for version: {newversion}"
101111
)
112+
changelog_tmp.close()
113+
os.rename(changelog_tmpname, changelog_name)
102114

103115
for toml_filename in toml_list:
104116
replace_toml_version(toml_filename, newversion)
105117

106118
for json_filename in json_list:
107119
update_package_json(json_filename, newversion)
108120

121+
with open("release-date.in", "w") as f:
122+
f.write(today)
123+
109124
print("running cargo check")
110125
subprocess.call(["cargo", "check"])
111126

0 commit comments

Comments
 (0)