-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrelease_changelog.py
64 lines (49 loc) · 1.86 KB
/
release_changelog.py
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
URL = "https://api.github.com/repos/hhd-dev/kernel-bazzite/releases"
import requests
import sys
import datetime
contributors = {"antheas": "Antheas Kapenekakis <[email protected]>"}
# * Wed Aug 28 2024 Fedora Kernel Team <[email protected]> [6.11.0-0.rc5.86987d84b968.45]
# - redhat: include resolve_btfids in kernel-devel (Jan Stancek)
# - redhat: workaround CKI cross compilation for scripts (Jan Stancek)
# - spec: fix "unexpected argument to non-parametric macro" warnings (Jan Stancek)
# - Linux v6.11.0-0.rc5.86987d84b968
def main():
res = requests.get(URL)
data = res.json()
out = ""
for release in data:
# Wed Aug 28 2024
date = datetime.datetime.strptime(
release["published_at"], "%Y-%m-%dT%H:%M:%SZ"
).strftime("%a %b %d %Y")
author = release["author"]["login"]
rel = release["tag_name"]
out += f"* {date} {contributors.get(author, author)} [{rel}]\n"
out += f"- {release['name'].replace(rel + ": ", '')}\n"
body_lines = release["body"].split("\n")
for line in body_lines:
parts = line.split(" ")
buf = ""
for part in parts:
if len(buf) + len(part) + 1 > 80 and not part.startswith("http"):
out += f" {buf}\n"
buf = part
else:
buf += f" {part}"
if buf:
out += f" {buf}\n"
out += "\n"
with open("kernel.spec", "r") as f:
spec = f.read()
spec = spec.replace("%changelog", "%changelog\n" + out)
with open("kernel.spec", "w") as f:
f.write(spec)
print(f"Wrote changelog:\n{out}")
if __name__ == "__main__":
for i in range(3):
try:
main()
break
except Exception as e:
print(f"Error:\n{e}. Retrying...", file=sys.stderr)