1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00
wezterm/ci/subst-release-info.py

89 lines
2.4 KiB
Python
Raw Normal View History

2019-12-30 08:24:08 +03:00
#!/usr/bin/env python3
import json
import sys
def release_to_links(rel):
source = None
macos = None
2020-02-13 06:20:36 +03:00
centos = None
2019-12-30 08:24:08 +03:00
fedora = None
ubuntu = None
windows = None
linux_bin = None
2020-01-26 23:46:15 +03:00
appimage = None
2019-12-30 08:24:08 +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"]
if "-src.tar.gz" in name:
source = (url, name, tag_name)
2019-12-30 08:24:08 +03:00
elif ".deb" in name:
ubuntu = (url, name, tag_name)
2019-12-30 08:24:08 +03:00
elif ".tar.xz" in name:
linux_bin = (url, name, tag_name)
2019-12-30 08:24:08 +03:00
elif ".rpm" in name:
2020-02-13 06:20:36 +03:00
if ('fedora' in name) or ('fc31' in name):
fedora = (url, name, tag_name)
if ('centos' in name) or ('el7' in name):
centos = (url, name, tag_name)
2019-12-30 08:24:08 +03:00
elif "WezTerm-macos-" in name:
macos = (url, name, tag_name)
2019-12-30 08:24:08 +03:00
elif "WezTerm-windows-" in name:
windows = (url, name, tag_name)
2020-01-26 23:46:15 +03:00
elif ".AppImage" in name:
appimage = (url, name, tag_name)
2019-12-30 08:24:08 +03:00
return {
"source": source,
"ubuntu": ubuntu,
"linux_bin": linux_bin,
"fedora": fedora,
2020-02-13 06:20:36 +03:00
"centos": centos,
2019-12-30 08:24:08 +03:00
"macos": macos,
"windows": windows,
2020-01-26 23:46:15 +03:00
"appimage": appimage,
2019-12-30 08:24:08 +03:00
}
def pretty(o):
return json.dumps(o, indent=4, sort_keys=True, separators=(',', ':'))
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)
latest = release_info[0]
nightly = None
for rel in release_info:
if rel["tag_name"] == "nightly":
nightly = rel
break
latest = release_to_links(latest)
nightly = release_to_links(nightly)
print('latest: ', pretty(latest))
print('nightly: ', pretty(nightly))
2019-12-30 08:24:08 +03:00
subst = {}
2020-01-26 23:46:15 +03:00
for (kind, info) in latest.items():
if info is None:
continue
url, name, dir = info
2019-12-30 08:24:08 +03:00
subst["{{ %s_stable }}" % kind] = url
subst["{{ %s_stable_asset }}" % kind] = name
subst["{{ %s_stable_dir }}" % kind] = dir
2019-12-30 08:24:08 +03:00
with open("docs/installation.markdown", "r") as input:
with open("docs/installation.md", "w") as output:
for line in input:
for (search, replace) in subst.items():
line = line.replace(search, replace)
output.write(line)
def main():
load_release_info()
main()