1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/usr/bin/env python3
"""Generate the "Quick Downloads" markdown block for a WSJT-X GitHub Release.
The release workflow attaches every build artifact to the Release, which makes
the assets list long and hard for an end user to navigate (installers sit among
the command-line program tarballs, checksums, the manifest, and source). This emits a
short, curated per-platform installer picker to put above the change list.
It is *asset-driven*: platforms and architectures are derived from the asset
filenames passed in, not hard-coded. New build variants (for example an added
Linux architecture such as armhf) therefore appear in Quick Downloads
automatically, with no edit to this script.
The block is emitted on stdout, ending at the last platform line (no trailing
separator); the caller joins it to the change list.
Usage:
generate-quick-downloads.py <owner/repo> <tag> <asset-path-or-name>...
Only installer-grade assets are listed (.pkg / win64.exe / .deb / .rpm /
.AppImage) plus the source tarball. The command-line program tarballs are
intentionally omitted; they remain in the full assets list below the notes.
"""
import os
import re
import sys
# Architectures listed first, in this order; any others are appended sorted.
ARCH_ORDER = ["x86_64", "aarch64", "armhf", "armv7l", "arm64", "i686"]
def main(argv):
if len(argv) < 4:
sys.stderr.write(
"usage: generate-quick-downloads.py <owner/repo> <tag> <asset>...\n"
)
return 2
repo, tag = argv[1], argv[2]
names = sorted({os.path.basename(p) for p in argv[3:] if p.strip()})
def url(name):
return f"https://github.com/{repo}/releases/download/{tag}/{name}"
macos = {} # label -> filename
windows = {} # label -> filename
deb = {} # arch -> filename
rpm = {} # arch -> filename
appimage = {} # arch -> filename
source = None
for n in names:
if n.endswith("-arm64-macOS.pkg"):
macos["Apple Silicon"] = n
elif n.endswith("-x86_64-macOS.pkg"):
macos["Intel"] = n
elif re.search(r"-win\d+\.exe$", n): # installer, not raw jt9.exe
windows["64-bit"] = n
elif n.endswith("-src.tar.gz"):
source = n
elif (m := re.search(r"-linux-([A-Za-z0-9_]+)\.deb$", n)):
deb[m.group(1)] = n
elif (m := re.search(r"-linux-([A-Za-z0-9_]+)\.AppImage$", n)):
appimage[m.group(1)] = n
elif (m := re.search(r"\.([A-Za-z0-9_]+)\.rpm$", n)):
rpm[m.group(1)] = n
# Anything else (program tarballs, checksums, the manifest) is
# intentionally excluded; it stays in the full assets list.
def arches(d):
known = [a for a in ARCH_ORDER if a in d]
extra = sorted(a for a in d if a not in ARCH_ORDER)
return known + extra
def arch_line(label, d):
return f"- {label}: " + " · ".join(
f"[{a}]({url(d[a])})" for a in arches(d)
)
out = [
"## Quick Downloads",
"",
"Choose the installer for your platform. The full assets list below also",
"includes the command-line program tarballs and source code for developers.",
]
if macos:
out += ["", "### macOS"]
if "Apple Silicon" in macos:
out.append(f"- Apple Silicon: [{macos['Apple Silicon']}]({url(macos['Apple Silicon'])})")
if "Intel" in macos:
out.append(f"- Intel: [{macos['Intel']}]({url(macos['Intel'])})")
if windows:
out += ["", "### Windows"]
out.append(f"- 64-bit: [{windows['64-bit']}]({url(windows['64-bit'])})")
if deb or rpm or appimage:
out += ["", "### Linux"]
if deb:
out.append(arch_line("Debian / Ubuntu (.deb)", deb))
if rpm:
out.append(arch_line("Fedora / RHEL (.rpm)", rpm))
if appimage:
out.append(arch_line("AppImage (universal)", appimage))
if source:
out += ["", "### Source", f"- [{source}]({url(source)})"]
# If nothing matched (no installer-grade assets), emit nothing; the caller
# then publishes the change list alone.
if len(out) == 4:
return 0
sys.stdout.write("\n".join(out) + "\n")
return 0
if __name__ == "__main__":
raise SystemExit(main(sys.argv))
|