2019-12-30 08:24:08 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import json
|
|
|
|
import sys
|
2020-05-04 03:14:46 +03:00
|
|
|
import re
|
2019-12-30 08:24:08 +03:00
|
|
|
|
2020-05-04 03:14:46 +03:00
|
|
|
CATEGORIZE = {
|
|
|
|
r".el7.x86_64.rpm$": "centos7_rpm",
|
|
|
|
r".centos7.rpm$": "centos7_rpm",
|
2020-05-04 18:21:30 +03:00
|
|
|
r".el8.x86_64.rpm$": "centos8_rpm",
|
|
|
|
r".centos8.rpm$": "centos8_rpm",
|
2020-05-04 03:14:46 +03:00
|
|
|
r".fc31.x86_64.rpm$": "fedora31_rpm",
|
|
|
|
r".fedora31.rpm$": "fedora31_rpm",
|
2020-05-04 17:38:14 +03:00
|
|
|
r".fc32.x86_64.rpm$": "fedora32_rpm",
|
|
|
|
r".fedora32.rpm$": "fedora32_rpm",
|
2020-12-05 09:09:48 +03:00
|
|
|
r".fc33.x86_64.rpm$": "fedora33_rpm",
|
|
|
|
r".fedora33.rpm$": "fedora33_rpm",
|
2021-05-02 19:32:38 +03:00
|
|
|
r".fc34.x86_64.rpm$": "fedora34_rpm",
|
|
|
|
r".fedora34.rpm$": "fedora34_rpm",
|
2020-05-04 03:14:46 +03:00
|
|
|
r"Debian9.12.deb$": "debian9_deb",
|
|
|
|
r"Debian10.deb$": "debian10_deb",
|
|
|
|
r"Ubuntu16.04.AppImage$": "ubuntu16_AppImage",
|
|
|
|
r"^WezTerm-.*.x86_64.AppImage$": "ubuntu16_AppImage",
|
|
|
|
r"Ubuntu16.04.deb$": "ubuntu16_deb",
|
|
|
|
r"^wezterm-\d+-\d+-[a-f0-9]+.deb$": "ubuntu16_deb",
|
|
|
|
r"Ubuntu18.04.deb$": "ubuntu18_deb",
|
2020-05-04 09:10:42 +03:00
|
|
|
r"Ubuntu20.04.deb$": "ubuntu20_deb",
|
2020-05-04 03:14:46 +03:00
|
|
|
r"Ubuntu16.04.tar.xz$": "linux_raw_bin",
|
|
|
|
r"^wezterm-\d+-\d+-[a-f0-9]+.tar.xz$": "linux_raw_bin",
|
|
|
|
r"src.tar.gz$": "src",
|
|
|
|
r"^WezTerm-macos-.*.zip$": "macos_zip",
|
|
|
|
r"^WezTerm-windows-.*.zip$": "windows_zip",
|
2020-05-25 22:52:06 +03:00
|
|
|
r"^WezTerm-.*.setup.exe$": "windows_exe",
|
2020-05-04 03:14:46 +03:00
|
|
|
}
|
2019-12-30 08:24:08 +03:00
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
|
2020-05-04 03:14:46 +03:00
|
|
|
def categorize(rel):
|
|
|
|
downloads = {}
|
2019-12-30 10:06:29 +03:00
|
|
|
|
2020-05-04 03:14:46 +03:00
|
|
|
tag_name = "wezterm-%s" % rel["tag_name"]
|
2019-12-30 08:24:08 +03:00
|
|
|
for asset in rel["assets"]:
|
|
|
|
url = asset["browser_download_url"]
|
|
|
|
name = asset["name"]
|
|
|
|
|
2020-05-04 03:14:46 +03:00
|
|
|
for k, v in CATEGORIZE.items():
|
|
|
|
if re.search(k, name):
|
|
|
|
downloads[v] = (url, name, tag_name)
|
|
|
|
|
|
|
|
return downloads
|
2019-12-30 08:24:08 +03:00
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
|
2020-01-10 18:11:59 +03:00
|
|
|
def pretty(o):
|
2021-03-03 19:45:58 +03:00
|
|
|
return json.dumps(o, indent=4, sort_keys=True, separators=(",", ":"))
|
|
|
|
|
2020-01-10 18:11:59 +03:00
|
|
|
|
2020-05-04 03:14:46 +03:00
|
|
|
def build_subst(subst, stable, categorized):
|
|
|
|
for (kind, info) in categorized.items():
|
|
|
|
if info is None:
|
|
|
|
continue
|
|
|
|
url, name, dir = info
|
|
|
|
kind = f"{kind}_{stable}"
|
|
|
|
subst["{{ %s }}" % kind] = url
|
|
|
|
subst["{{ %s_asset }}" % kind] = name
|
|
|
|
subst["{{ %s_dir }}" % kind] = dir
|
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
|
2019-12-30 08:24:08 +03:00
|
|
|
def load_release_info():
|
|
|
|
with open("/tmp/wezterm.releases.json") as f:
|
|
|
|
release_info = json.load(f)
|
|
|
|
|
2021-04-05 22:29:13 +03:00
|
|
|
with open("/tmp/wezterm.nightly.json") as f:
|
|
|
|
nightly = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
latest = None
|
2019-12-30 08:24:08 +03:00
|
|
|
for rel in release_info:
|
2021-04-05 22:29:13 +03:00
|
|
|
if rel["prerelease"]:
|
|
|
|
continue
|
|
|
|
latest = rel
|
|
|
|
break
|
2019-12-30 08:24:08 +03:00
|
|
|
|
2020-05-04 03:14:46 +03:00
|
|
|
latest = categorize(latest)
|
|
|
|
nightly = categorize(nightly)
|
2019-12-30 08:24:08 +03:00
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
print("latest: ", pretty(latest))
|
|
|
|
print("nightly: ", pretty(nightly))
|
2020-01-10 18:11:59 +03:00
|
|
|
|
2019-12-30 08:24:08 +03:00
|
|
|
subst = {}
|
2020-05-04 03:14:46 +03:00
|
|
|
build_subst(subst, "stable", latest)
|
|
|
|
build_subst(subst, "nightly", nightly)
|
|
|
|
print(pretty(subst))
|
2019-12-30 10:06:29 +03:00
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
for name in [
|
|
|
|
"install/windows",
|
|
|
|
"install/macos",
|
|
|
|
"install/linux",
|
|
|
|
"install/source",
|
|
|
|
"install/freebsd",
|
|
|
|
]:
|
2020-05-30 20:30:32 +03:00
|
|
|
with open(f"docs/{name}.markdown", "r") as input:
|
|
|
|
with open(f"docs/{name}.md", "w") as output:
|
|
|
|
for line in input:
|
|
|
|
for (search, replace) in subst.items():
|
|
|
|
line = line.replace(search, replace)
|
|
|
|
output.write(line)
|
2019-12-30 08:24:08 +03:00
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
|
2019-12-30 08:24:08 +03:00
|
|
|
def main():
|
|
|
|
load_release_info()
|
|
|
|
|
2021-03-03 19:45:58 +03:00
|
|
|
|
2019-12-30 08:24:08 +03:00
|
|
|
main()
|