1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

docs: code generation for release info

This commit is contained in:
Wez Furlong 2019-12-29 21:24:08 -08:00
parent a11f036d87
commit 4681436bd1
6 changed files with 84 additions and 48 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@
/pkg /pkg
/target/ /target/
/gh_pages/ /gh_pages/
/docs/installation.md
**/*.rs.bk **/*.rs.bk
.*.sw* .*.sw*
/esctest.log /esctest.log

6
ci/build-docs.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
[[ -f /tmp/wezterm.releases.json ]] || curl https://api.github.com/repos/wez/wezterm/releases > /tmp/wezterm.releases.json
python3 ci/subst-release-info.py
mdbook build docs

71
ci/subst-release-info.py Normal file
View File

@ -0,0 +1,71 @@
#!/usr/bin/env python3
import json
import sys
def release_to_links(rel):
source = None
macos = None
fedora = None
ubuntu = None
windows = None
linux_bin = None
for asset in rel["assets"]:
url = asset["browser_download_url"]
name = asset["name"]
if "-src.tar.gz" in name:
source = (url, name)
elif ".deb" in name:
ubuntu = (url, name)
elif ".tar.xz" in name:
linux_bin = (url, name)
elif ".rpm" in name:
fedora = (url, name)
elif "WezTerm-macos-" in name:
macos = (url, name)
elif "WezTerm-windows-" in name:
windows = (url, name)
return {
"source": source,
"ubuntu": ubuntu,
"linux_bin": linux_bin,
"fedora": fedora,
"macos": macos,
"windows": windows,
}
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)
subst = {}
for (kind, (url, name)) in latest.items():
subst["{{ %s_stable }}" % kind] = url
subst["{{ %s_stable_asset }}" % kind] = name
for (kind, (url, name)) in nightly.items():
subst["{{ %s_pre }}" % kind] = url
subst["{{ %s_pre_asset }}" % kind] = name
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()

View File

@ -1,5 +1,5 @@
[wezterm](index.markdown) [wezterm](index.markdown)
- [Install](installation.markdown) - [Install](installation.md)
- [Features](features.markdown) - [Features](features.markdown)
- [Change Log](changelog.markdown) - [Change Log](changelog.markdown)
- [Configuration](config/index.markdown) - [Configuration](config/index.markdown)

View File

@ -6,4 +6,3 @@ src = "."
[build] [build]
build-dir = "../gh_pages" build-dir = "../gh_pages"
create-missing = false create-missing = false

View File

@ -1,44 +1,3 @@
---
title: Installation
---
{% assign releases = site.github.releases | sort:"created_at" | reverse %}
{% for r in releases %}
{% if r.prerelease %}
{% for asset in r.assets %}
{% if asset.name contains 'windows' and windows_pre == nil %}
{% assign windows_pre = asset.browser_download_url %}
{% endif %}
{% if asset.name contains 'macos' and macos_pre == nil %}
{% assign macos_pre = asset.browser_download_url %}
{% endif %}
{% if asset.name contains '.deb' and deb_pre == nil %}
{% assign deb_pre = asset.browser_download_url %}
{% endif %}
{% if asset.name contains '.rpm' and fedora_pre == nil %}
{% assign fedora_pre = asset.browser_download_url %}
{% endif %}
{% endfor %}
{% else %}
{% for asset in r.assets %}
{% if asset.name contains 'windows' and windows_stable == nil %}
{% assign windows_stable = asset.browser_download_url %}
{% endif %}
{% if asset.name contains 'macos' and macos_stable == nil %}
{% assign macos_stable = asset.browser_download_url %}
{% endif %}
{% if asset.name contains '.deb' and deb_stable == nil %}
{% assign deb_stable = asset.browser_download_url %}
{% assign deb_stable_asset = asset.name %}
{% endif %}
{% if asset.name contains '.rpm' and fedora_stable == nil %}
{% assign fedora_stable = asset.browser_download_url %}
{% assign fedora_stable_asset = asset.name %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
## Installing a pre-built package on Windows ## Installing a pre-built package on Windows
@ -69,10 +28,10 @@ versions of macOS, but that has not been tested.
The CI system builds a `.deb` file on Ubuntu 16.04. It is compatible with other The CI system builds a `.deb` file on Ubuntu 16.04. It is compatible with other
debian style systems, including Debian 9 (Stretch) and later versions. debian style systems, including Debian 9 (Stretch) and later versions.
<a href="{{ deb_stable }}" class="btn">Download for Ubuntu</a> <a href="{{ ubuntu_stable }}" class="btn">Download for Ubuntu</a>
<a href="{{ deb_pre }}" class="btn">Nightly for Ubuntu</a> <a href="{{ ubuntu_pre }}" class="btn">Nightly for Ubuntu</a>
* <tt>curl -LO <a href="{{ deb_stable }}">{{ deb_stable }}</a></tt> * <tt>curl -LO <a href="{{ ubuntu_stable }}">{{ ubuntu_stable }}</a></tt>
* `sudo apt install -y ./{{ deb_stable_asset }}` * `sudo apt install -y ./{{ ubuntu_stable_asset }}`
* The package installs `/usr/bin/wezterm` and `/usr/share/applications/wezterm.desktop` * The package installs `/usr/bin/wezterm` and `/usr/share/applications/wezterm.desktop`
* Configuration instructions can be [found here](configuration.html) * Configuration instructions can be [found here](configuration.html)
@ -81,7 +40,7 @@ debian style systems, including Debian 9 (Stretch) and later versions.
The CI system builds an `.rpm` file on Fedora 31. The CI system builds an `.rpm` file on Fedora 31.
<a href="{{ fedora_stable }}" class="btn">Download for Fedora</a> <a href="{{ fedora_stable }}" class="btn">Download for Fedora</a>
<a href="{{ fedora_pre }}" class="btn">{Nightly for Fedora</a> <a href="{{ fedora_pre }}" class="btn">Nightly for Fedora</a>
* <tt>curl -LO <a href="{{ fedora_stable }}">{{ fedora_stable }}</a></tt> * <tt>curl -LO <a href="{{ fedora_stable }}">{{ fedora_stable }}</a></tt>
* `sudo dnf install -y ./{{ fedora_stable_asset }}` * `sudo dnf install -y ./{{ fedora_stable_asset }}`
* The package installs `/usr/bin/wezterm` and `/usr/share/applications/wezterm.desktop` * The package installs `/usr/bin/wezterm` and `/usr/share/applications/wezterm.desktop`