mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 15:02:11 +03:00
- [x] figgure out how to build the packages (that it installs native optional package automatically) - [X] Make the gluecode - [x] expose both the lowerlevel api that desktop uses (~~send objects and receive objects~~, getting path of rpc-server is enough) - [X] and the higher level api needed for bots (jsonrpc client) - [X] typescript types - [x] automatically pick the right binary from npm or allow getting it from env var, or give out an error (throw error) - [x] find out how to dev locally (use local built core in dc desktop) - there is the question of how to link the typescript client and the task to add a search in the cargo target folder for a debug build or a different way, find out some good flow that we can use and document for dc desktop + locally built core development - [x] build the packages in ci - [x] fix that deltachat-rpc-server is not executable postponed: - [ ] publish from ci - [ ] add key/token to deploy to npm Closes #4694 ## Related prs - https://github.com/deltachat-bot/echo/pull/69 - https://github.com/deltachat/deltachat-desktop/pull/3567 --------- Co-authored-by: link2xt <link2xt@testrun.org>
143 lines
3.8 KiB
Python
Executable File
143 lines
3.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import datetime
|
|
import json
|
|
import os
|
|
import pathlib
|
|
import re
|
|
import subprocess
|
|
from argparse import ArgumentParser
|
|
from pathlib import Path
|
|
|
|
rex = re.compile(r'version = "(\S+)"')
|
|
|
|
|
|
def regex_matches(relpath, regex=rex):
|
|
p = pathlib.Path(relpath)
|
|
assert p.exists()
|
|
for line in open(str(p)):
|
|
m = regex.match(line)
|
|
if m is not None:
|
|
return m
|
|
|
|
|
|
def read_toml_version(relpath):
|
|
res = regex_matches(relpath, rex)
|
|
if res is not None:
|
|
return res.group(1)
|
|
raise ValueError(f"no version found in {relpath}")
|
|
|
|
|
|
def replace_toml_version(relpath, newversion):
|
|
p = pathlib.Path(relpath)
|
|
assert p.exists()
|
|
tmp_path = str(p) + "_tmp"
|
|
with open(tmp_path, "w") as f:
|
|
for line in open(str(p)):
|
|
m = rex.match(line)
|
|
if m is not None:
|
|
print(f"{relpath}: set version={newversion}")
|
|
f.write(f'version = "{newversion}"\n')
|
|
else:
|
|
f.write(line)
|
|
os.rename(tmp_path, str(p))
|
|
|
|
|
|
def read_json_version(relpath):
|
|
p = pathlib.Path(relpath)
|
|
assert p.exists()
|
|
with open(p) as f:
|
|
json_data = json.loads(f.read())
|
|
return json_data["version"]
|
|
|
|
|
|
def update_package_json(relpath, newversion):
|
|
p = pathlib.Path(relpath)
|
|
assert p.exists()
|
|
with open(p) as f:
|
|
json_data = json.loads(f.read())
|
|
json_data["version"] = newversion
|
|
with open(p, "w") as f:
|
|
json.dump(json_data, f, sort_keys=True, indent=2)
|
|
f.write("\n")
|
|
|
|
|
|
def main():
|
|
parser = ArgumentParser(prog="set_core_version")
|
|
parser.add_argument("newversion")
|
|
|
|
json_list = [
|
|
"package.json",
|
|
"deltachat-jsonrpc/typescript/package.json",
|
|
"deltachat-rpc-server/npm-package/package.json",
|
|
]
|
|
toml_list = [
|
|
"Cargo.toml",
|
|
"deltachat-ffi/Cargo.toml",
|
|
"deltachat-jsonrpc/Cargo.toml",
|
|
"deltachat-rpc-server/Cargo.toml",
|
|
"deltachat-repl/Cargo.toml",
|
|
"python/pyproject.toml",
|
|
"deltachat-rpc-client/pyproject.toml",
|
|
]
|
|
try:
|
|
opts = parser.parse_args()
|
|
except SystemExit:
|
|
print()
|
|
for x in toml_list:
|
|
print(f"{x}: {read_toml_version(x)}")
|
|
for x in json_list:
|
|
print(f"{x}: {read_json_version(x)}")
|
|
print()
|
|
raise SystemExit("need argument: new version, example: 1.25.0")
|
|
|
|
newversion = opts.newversion
|
|
if newversion.count(".") < 2:
|
|
raise SystemExit("need at least two dots in version")
|
|
|
|
core_toml = read_toml_version("Cargo.toml")
|
|
ffi_toml = read_toml_version("deltachat-ffi/Cargo.toml")
|
|
assert core_toml == ffi_toml, (core_toml, ffi_toml)
|
|
|
|
today = datetime.date.today().isoformat()
|
|
|
|
if "alpha" not in newversion:
|
|
found = False
|
|
for line in Path("CHANGELOG.md").open():
|
|
if line == f"## [{newversion}] - {today}\n":
|
|
found = True
|
|
if not found:
|
|
raise SystemExit(
|
|
f"CHANGELOG.md contains no entry for version: {newversion}"
|
|
)
|
|
|
|
for toml_filename in toml_list:
|
|
replace_toml_version(toml_filename, newversion)
|
|
|
|
for json_filename in json_list:
|
|
update_package_json(json_filename, newversion)
|
|
|
|
with open("release-date.in", "w") as f:
|
|
f.write(today)
|
|
|
|
print("running cargo check")
|
|
subprocess.call(["cargo", "check"])
|
|
|
|
print("adding changes to git index")
|
|
subprocess.call(["git", "add", "-u"])
|
|
# subprocess.call(["cargo", "update", "-p", "deltachat"])
|
|
|
|
print("After commit, make sure to:")
|
|
print()
|
|
print(f" git tag -a v{newversion}")
|
|
print(f" git push origin v{newversion}")
|
|
print(f" gh release create v{newversion} -n ''")
|
|
print()
|
|
print("Merge release branch into `master` if the release")
|
|
print("is made on a stable branch.")
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|