Clean up appdata releases update script
- Simplify code - Fix output date for the 0.6.0 release - Move to the packaging dir with a more descriptive filename
This commit is contained in:
parent
0ad1466acd
commit
e50a7531ee
|
@ -55,20 +55,20 @@
|
|||
</screenshots>
|
||||
<metadata_license>FSFAP</metadata_license>
|
||||
<releases>
|
||||
<release version="0.7.1" date="2021-03-04" />
|
||||
<release version="0.7.0" date="2021-02-28" />
|
||||
<release version="0.6.4" date="2020-09-16" />
|
||||
<release version="0.6.3" date="2020-09-16" />
|
||||
<release version="0.6.2" date="2020-08-28" />
|
||||
<release version="0.6.1" date="2020-08-21" />
|
||||
<release version="0.6.0" date="2020-07-1" />
|
||||
<release version="0.5.2" date="2020-06-26" />
|
||||
<release version="0.5.1" date="2020-06-05" />
|
||||
<release version="0.5.0" date="2020-05-22" />
|
||||
<release version="0.4.3" date="2020-04-03" />
|
||||
<release version="0.4.2" date="2020-03-27" />
|
||||
<release version="0.4.1" date="2020-03-23" />
|
||||
<release version="0.4.0" date="2020-03-21" />
|
||||
<release version="0.7.1" date="2021-03-04"/>
|
||||
<release version="0.7.0" date="2021-02-28"/>
|
||||
<release version="0.6.4" date="2020-09-16"/>
|
||||
<release version="0.6.3" date="2020-09-16"/>
|
||||
<release version="0.6.2" date="2020-08-28"/>
|
||||
<release version="0.6.1" date="2020-08-21"/>
|
||||
<release version="0.6.0" date="2020-07-17"/>
|
||||
<release version="0.5.2" date="2020-06-26"/>
|
||||
<release version="0.5.1" date="2020-06-05"/>
|
||||
<release version="0.5.0" date="2020-05-22"/>
|
||||
<release version="0.4.3" date="2020-04-03"/>
|
||||
<release version="0.4.2" date="2020-03-27"/>
|
||||
<release version="0.4.1" date="2020-03-23"/>
|
||||
<release version="0.4.0" date="2020-03-21"/>
|
||||
</releases>
|
||||
<custom>
|
||||
<value key="Purism::form_factor">workstation</value>
|
||||
|
|
32
packaging/update-appdata-releases.py
Executable file
32
packaging/update-appdata-releases.py
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import html
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
title_pattern = re.compile(r"## (\d+\.\d+\.\d+) \((\d{4}-\d\d-\d\d)\)")
|
||||
release_lines = [" <releases>"]
|
||||
|
||||
for line in (root / "docs" / "CHANGELOG.md").read_text().splitlines():
|
||||
match = title_pattern.match(line)
|
||||
|
||||
if match:
|
||||
args = (html.escape(match.group(1)), html.escape(match.group(2)))
|
||||
release_lines.append(' <release version="%s" date="%s"/>' % args)
|
||||
|
||||
appdata = root / "packaging" / "mirage.appdata.xml"
|
||||
in_releases = False
|
||||
final_lines = []
|
||||
|
||||
for line in appdata.read_text().splitlines():
|
||||
if line == " <releases>":
|
||||
in_releases = True
|
||||
final_lines += release_lines
|
||||
elif line == " </releases>":
|
||||
in_releases = False
|
||||
|
||||
if not in_releases:
|
||||
final_lines.append(line)
|
||||
|
||||
appdata.write_text("\n".join(final_lines))
|
|
@ -1,68 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import html
|
||||
import mistune
|
||||
import re
|
||||
|
||||
|
||||
def get_src_path():
|
||||
return str(Path(__file__).resolve().parent)
|
||||
|
||||
|
||||
def make_changelog_dict(title):
|
||||
title_parts = title.split(" ")
|
||||
|
||||
return {
|
||||
"date": title_parts[2][1:-2],
|
||||
"version": title_parts[1]
|
||||
}
|
||||
|
||||
|
||||
def make_release_tag(version, date):
|
||||
return " <release version=\"" + html.escape(version) \
|
||||
+ "\" date=\"" + html.escape(date) \
|
||||
+ "\" />\n" \
|
||||
|
||||
|
||||
markdown_parser = mistune.Markdown(escape=False)
|
||||
changelog_title_pattern = re.compile(r"##\ \d\.\d\.\d\ \(\d{4}-\d{2}-\d{2}\)")
|
||||
changelog_lines = open(get_src_path() + "/docs/CHANGELOG.md", "r").readlines()
|
||||
changelog_entries = []
|
||||
|
||||
for line in changelog_lines:
|
||||
if changelog_title_pattern.match(line):
|
||||
changelog_entry = make_changelog_dict(line)
|
||||
changelog_entries.append(changelog_entry)
|
||||
|
||||
appdata_releases = ""
|
||||
|
||||
for entry in changelog_entries:
|
||||
appdata_releases += make_release_tag(entry["version"], entry["date"])
|
||||
|
||||
appdata_path = get_src_path() + "/packaging/mirage.appdata.xml"
|
||||
appdata_lines = open(appdata_path, "r").readlines()
|
||||
releases_open_pattern = re.compile(r" <releases>")
|
||||
releases_close_pattern = re.compile(r" </releases>")
|
||||
|
||||
opening_tag_found = False
|
||||
releases_open_line = 0
|
||||
releases_close_line = 0
|
||||
|
||||
for line in appdata_lines:
|
||||
if not opening_tag_found:
|
||||
releases_open_line += 1
|
||||
if releases_open_pattern.match(line):
|
||||
opening_tag_found = True
|
||||
if releases_close_pattern.match(line):
|
||||
break
|
||||
releases_close_line += 1
|
||||
|
||||
# We need to remove the old release entries since we're inserting
|
||||
# new ones unconditionally
|
||||
del appdata_lines[releases_open_line:releases_close_line]
|
||||
appdata_lines.insert(releases_open_line, appdata_releases)
|
||||
|
||||
with open(appdata_path, "w") as appdata_file:
|
||||
appdata_lines = "".join(appdata_lines)
|
||||
appdata_file.write(appdata_lines)
|
Loading…
Reference in New Issue
Block a user