Update metainfo xml file

This commit is contained in:
WardPearce
2025-02-21 12:02:19 +13:00
parent 20b954fa82
commit 1ef6c4b23b
5 changed files with 57 additions and 35 deletions
+2 -2
View File
@@ -7,8 +7,8 @@ android {
applicationId "us.materialio.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 92
versionName "1.7.10"
versionCode 93
versionName "1.7.11"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
@@ -53,7 +53,11 @@
<content_attribute id="social-contacts">intense</content_attribute>
</content_rating>
<releases>
<release version="1.6.25" date="2025-1-03">
<release version="1.7.11" date="2025-2-21">
<url>https://github.com/Materialious/Materialious/releases/tag/1.7.11</url>
</release>
<release version="1.6.25" date="2025-1-03">
<url>https://github.com/Materialious/Materialious/releases/tag/1.6.25</url>
</release>
<release version="1.6.18" date="2024-10-26">
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Materialious",
"version": "1.7.10",
"version": "1.7.11",
"description": "Modern material design for Invidious.",
"author": {
"name": "Ward Pearce",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "materialious",
"version": "1.7.10",
"version": "1.7.11",
"private": true,
"scripts": {
"dev": "vite dev",
+48 -30
View File
@@ -1,54 +1,72 @@
"""Small script for keeping versioning consistent for Materialious
"""
import json
import os
import re
from datetime import datetime
LATEST_VERSION = "1.7.11"
RELEASE_DATE = datetime.now().strftime("%Y-%-m-%d") # Format: YYYY-M-D
LATEST_VERSION = "1.7.10"
WORKING_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "materialious")
ROOT_PACKAGE = os.path.join(WORKING_DIR, "package.json")
ELECTRON_PACKAGE = os.path.join(WORKING_DIR, "electron", "package.json")
ANDROID_PACKAGE = os.path.join(WORKING_DIR, "android", "app", "build.gradle")
METAINFO_FILE = os.path.join(WORKING_DIR, "electron", "materialious.metainfo.xml")
def package_json_update_ver(location: str) -> None:
with open(location, "r") as f_:
package = json.loads(f_.read())
package = json.load(f_)
if package["version"] == LATEST_VERSION:
return
package["version"] = LATEST_VERSION
with open(location, "w") as f_:
f_.write(json.dumps(package, indent="\t"))
json.dump(package, f_, indent="\t")
def update_android_version() -> None:
with open(ANDROID_PACKAGE, "r") as f_:
contents = f_.read()
version_code_match = re.search(r"versionCode\s+(\d+)", contents)
version_name_match = re.search(r'versionName\s+"([^"]+)"', contents)
if version_code_match and version_name_match:
version_code = int(version_code_match.group(1)) + 1
contents = re.sub(r"versionCode\s+\d+", f"versionCode {version_code}", contents)
contents = re.sub(
r'versionName\s+"[^"]+"', f'versionName "{LATEST_VERSION}"', contents
)
with open(ANDROID_PACKAGE, "w") as f_:
f_.write(contents)
def update_metainfo_release() -> None:
with open(METAINFO_FILE, "r") as f_:
contents = f_.read()
# Check if the version already exists in the releases
if re.search(rf'<release version="{re.escape(LATEST_VERSION)}"', contents):
print(f"Release version {LATEST_VERSION} already exists.")
return
new_release = f"""
<release version="{LATEST_VERSION}" date="{RELEASE_DATE}">
<url>https://github.com/Materialious/Materialious/releases/tag/{LATEST_VERSION}</url>
</release>"""
# Insert the new release after the opening <releases> tag
updated_contents = re.sub(r"(<releases>\s*)", rf"\1{new_release}\n", contents)
with open(METAINFO_FILE, "w") as f_:
f_.write(updated_contents)
if __name__ == "__main__":
for location in (ROOT_PACKAGE, ELECTRON_PACKAGE):
package_json_update_ver(location)
with open(ANDROID_PACKAGE, "r") as f_:
contents = f_.read()
version_code_match = re.search(r"versionCode\s+(\d+)", contents)
version_name_match = re.search(r'versionName\s+"([^"]+)"', contents)
if version_code_match and version_name_match:
version_code = version_code_match.group(1)
version_name = version_name_match.group(1)
f_.close()
with open(ANDROID_PACKAGE, "w") as f_:
new_version_code = int(version_code) + 1
f_.write(
contents.replace(
f"versionCode {version_code}", f"versionCode {new_version_code}"
).replace(
f'versionName "{version_name}"',
f'versionName "{LATEST_VERSION}"',
)
)
update_android_version()
update_metainfo_release()