Skip to content

Commit 952b4e5

Browse files
committed
appdata: Populate with initial and recent releases.
We've only ever provided the 'current' release as part of building our appdata file, but Flathub now has a section to show updates, and shows incorrect information. Add a script to add a new release to the appdata file (to be edited after), based on the most recent debian/changelog entry.
1 parent 2faebac commit 952b4e5

File tree

3 files changed

+109
-10
lines changed

3 files changed

+109
-10
lines changed

add-appdata-release.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env python3
2+
"""Prepend a new <release> entry to the appdata template.
3+
4+
Pulls the version, date, and bullet list from the most recent
5+
debian/changelog entry. Intended to be run manually after a release
6+
has been tagged and the changelog updated. Review and edit the
7+
generated description before committing.
8+
"""
9+
import re
10+
import sys
11+
from email.utils import parsedate_to_datetime
12+
from pathlib import Path
13+
14+
REPO_ROOT = Path(__file__).resolve().parent
15+
CHANGELOG = REPO_ROOT / 'debian' / 'changelog'
16+
APPDATA = REPO_ROOT / 'data' / 'org.x.Warpinator.appdata.xml.in.in'
17+
18+
HEADER_RE = re.compile(r'^\S+\s+\(([^)]+)\)')
19+
TRAILER_RE = re.compile(r'^ -- .+?<.+?>\s+(.+)$')
20+
BULLET_RE = re.compile(r'^\s*\*\s+(.+?)\s*$')
21+
22+
23+
def parse_top_entry(path):
24+
with open(path, 'r', encoding='utf-8') as f:
25+
lines = f.readlines()
26+
27+
m = HEADER_RE.match(lines[0])
28+
if not m:
29+
sys.exit(f"Couldn't parse version from first line of {path}")
30+
version = m.group(1)
31+
32+
bullets = []
33+
date = None
34+
for line in lines[1:]:
35+
trailer = TRAILER_RE.match(line)
36+
if trailer:
37+
date = parsedate_to_datetime(trailer.group(1).strip()).strftime('%Y-%m-%d')
38+
break
39+
bullet = BULLET_RE.match(line)
40+
if bullet:
41+
bullets.append(bullet.group(1))
42+
43+
if date is None:
44+
sys.exit(f"Couldn't find trailer line in top entry of {path}")
45+
46+
return version, date, bullets
47+
48+
49+
def xml_escape(s):
50+
return s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
51+
52+
53+
def build_release_block(version, date, bullets):
54+
lines = [f' <release version="{version}" date="{date}">',
55+
' <description>']
56+
if len(bullets) <= 1:
57+
text = bullets[0] if bullets else 'Maintenance release.'
58+
lines.append(f' <p>{xml_escape(text)}</p>')
59+
else:
60+
lines.append(' <ul>')
61+
for b in bullets:
62+
lines.append(f' <li>{xml_escape(b)}</li>')
63+
lines.append(' </ul>')
64+
lines += [' </description>', ' </release>', '']
65+
return '\n'.join(lines)
66+
67+
68+
def main():
69+
version, date, bullets = parse_top_entry(CHANGELOG)
70+
71+
text = APPDATA.read_text(encoding='utf-8')
72+
if re.search(rf'<release version="{re.escape(version)}"', text):
73+
sys.exit(f"Release {version} is already present in {APPDATA.name}")
74+
75+
marker = ' <releases>\n'
76+
if marker not in text:
77+
sys.exit(f"Couldn't find <releases> block in {APPDATA.name}")
78+
79+
block = build_release_block(version, date, bullets)
80+
APPDATA.write_text(text.replace(marker, marker + block, 1), encoding='utf-8')
81+
82+
print(f"Added release {version} ({date}) to {APPDATA.relative_to(REPO_ROOT)}")
83+
print(f" bullets: {len(bullets)}")
84+
print("Review the description and edit wording before committing.")
85+
86+
87+
if __name__ == '__main__':
88+
main()

data/meson.build

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,8 @@ if include_firewall_mod
4444
)
4545
endif
4646

47-
current_date = run_command('sh', '-c', '''
48-
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-`date +%s`}";
49-
FORMAT="+%Y-%m-%d";
50-
date -u -d @"$SOURCE_DATE_EPOCH" "$FORMAT" 2>/dev/null ||
51-
date -u -r "$SOURCE_DATE_EPOCH" "$FORMAT" 2>/dev/null ||
52-
date -u "$FORMAT"''', check: false).stdout().strip()
53-
5447
appdata_conf = configuration_data()
5548
appdata_conf.set('appid', desktop_id)
56-
appdata_conf.set('app_version', meson.project_version())
57-
appdata_conf.set('current_date', current_date)
5849

5950
appdata = i18n.merge_file(
6051
input: configure_file(

data/org.x.Warpinator.appdata.xml.in.in

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,27 @@
3737
<dbus type="session">@appid@</dbus>
3838
</provides>
3939
<releases>
40-
<release version="@app_version@" date="@current_date@" />
40+
<release version="2.0.3" date="2026-01-08">
41+
<description>
42+
<p>Translation updates.</p>
43+
</description>
44+
</release>
45+
<release version="2.0.0" date="2025-11-21">
46+
<description>
47+
<ul>
48+
<li>IPv6 support.</li>
49+
<li>Switched to XApp symbolic icons.</li>
50+
<li>Ability to send text messages between devices.</li>
51+
<li>Detect URLs in messages and make them clickable.</li>
52+
<li>Fix reconnecting when the certificate is unchanged.</li>
53+
</ul>
54+
</description>
55+
</release>
56+
<release version="1.0.0" date="2020-04-17">
57+
<description>
58+
<p>Initial release.</p>
59+
</description>
60+
</release>
4161
</releases>
4262
<!-- DO NOT TRANSLATE Linux Mint -->
4363
<screenshots>

0 commit comments

Comments
 (0)