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 = {
|
2022-08-09 19:05:29 +03:00
|
|
|
r".centos(\d+)(:?\S+)?.rpm$": "centos\\1_rpm",
|
|
|
|
r".fedora(\d+)(:?\S+)?.rpm$": "fedora\\1_rpm",
|
2022-06-25 03:19:39 +03:00
|
|
|
r".el(\d+).x86_64.rpm$": "centos\\1_rpm",
|
|
|
|
r".fc(\d+).x86_64.rpm$": "fedora\\1_rpm",
|
2022-08-11 18:27:11 +03:00
|
|
|
r".opensuse_leap(.*).rpm$": "opensuse_leap_rpm",
|
|
|
|
r".opensuse_tumbleweed(.*).rpm$": "opensuse_tumbleweed_rpm",
|
2022-06-25 03:19:39 +03:00
|
|
|
r"Debian(\d+)(\.\d+)?\.deb$": "debian\\1_deb",
|
|
|
|
r"Ubuntu(\d+)(\.\d+)?.AppImage$": "ubuntu\\1_AppImage",
|
|
|
|
r"Ubuntu(\d+)(\.\d+)?.deb$": "ubuntu\\1_deb",
|
2023-04-16 19:16:54 +03:00
|
|
|
r"Ubuntu20.04.tar.xz$": "linux_raw_bin",
|
2020-05-04 03:14:46 +03:00
|
|
|
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",
|
2022-08-11 18:27:11 +03:00
|
|
|
r"alpine(\d+)\.(\d+)(:?-\S+)?.apk": "alpine\\1_\\2_apk",
|
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():
|
2022-06-25 03:19:39 +03:00
|
|
|
matches = re.search(k, name)
|
|
|
|
if matches:
|
|
|
|
v = matches.expand(v)
|
2020-05-04 03:14:46 +03:00
|
|
|
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):
|
2023-03-16 08:56:44 +03:00
|
|
|
for kind, info in categorized.items():
|
2020-05-04 03:14:46 +03:00
|
|
|
if info is None:
|
|
|
|
continue
|
|
|
|
url, name, dir = info
|
|
|
|
kind = f"{kind}_{stable}"
|
2023-03-21 19:31:49 +03:00
|
|
|
subst[kind] = url
|
|
|
|
subst[f"{kind}_asset"] = name
|
|
|
|
subst[f"{kind}_dir"] = dir
|
2020-05-04 03:14:46 +03:00
|
|
|
|
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:
|
2022-12-20 08:11:01 +03:00
|
|
|
if type(rel) is str:
|
|
|
|
print("Error", pretty(release_info))
|
|
|
|
raise Exception("Error obtaining release info")
|
|
|
|
|
2023-03-16 08:56:44 +03:00
|
|
|
# print(pretty(rel))
|
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
|
|
|
|
2023-03-16 08:56:44 +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)
|
2023-03-21 19:31:49 +03:00
|
|
|
|
|
|
|
with open(f"docs/releases.json", "w") as output:
|
|
|
|
json.dump(subst, output)
|
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()
|