Compare commits

...

1 Commits

Author SHA1 Message Date
karol 118e072344 fix: build complete manifest version history dynamically from Gitea releases API
Build and Release Plugin / release (push) Failing after 33s
2026-09-17 21:51:42 +02:00
+92 -40
View File
@@ -136,8 +136,73 @@ jobs:
except Exception as e:
print(f"Asset upload error: {e}")
# 3. Update manifest.json on master branch
clean_ver = tag.lstrip("v").split("-")[0]
# 3. Build manifest.json dynamically from Gitea Releases API
rel_list_req = urllib.request.Request(f"{api_url}/repos/{repo}/releases?per_page=100", headers=headers)
all_releases = []
try:
res_list = urllib.request.urlopen(rel_list_req)
all_releases = json.loads(res_list.read().decode("utf-8"))
except Exception as e:
print(f"Notice fetching releases list: {e}")
all_versions = []
for r in all_releases:
rel_tag = r.get("tag_name")
if not rel_tag:
continue
clean_v = rel_tag.lstrip("v").split("-")[0]
ts = r.get("published_at") or r.get("created_at") or "2026-09-17T20:00:00Z"
assets = r.get("assets", [])
if rel_tag == tag:
all_versions.append({
"version": clean_v,
"changelog": f"Release {tag} (Jellyfin 12.0)",
"targetAbi": "12.0.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{tag}/BlackBarRemover_{tag}_jf12.0.zip",
"checksum": md5_10,
"timestamp": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
})
all_versions.append({
"version": clean_v,
"changelog": f"Release {tag} (Jellyfin 10.11)",
"targetAbi": "10.11.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{tag}/BlackBarRemover_{tag}_jf10.11.zip",
"checksum": md5_9,
"timestamp": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
})
else:
a12 = next((a for a in assets if "jf12.0" in a.get("name", "")), None)
if a12:
all_versions.append({
"version": clean_v,
"changelog": f"Release {rel_tag} (Jellyfin 12.0)",
"targetAbi": "12.0.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{rel_tag}/{a12['name']}",
"checksum": a12.get("md5") or "",
"timestamp": ts
})
a10 = next((a for a in assets if "jf10.11" in a.get("name", "")), None)
if a10:
all_versions.append({
"version": clean_v,
"changelog": f"Release {rel_tag} (Jellyfin 10.11)",
"targetAbi": "10.11.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{rel_tag}/{a10['name']}",
"checksum": a10.get("md5") or "",
"timestamp": ts
})
if not a12 and not a10 and assets:
alegacy = assets[0]
all_versions.append({
"version": clean_v,
"changelog": f"Release {rel_tag}",
"targetAbi": "10.9.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{rel_tag}/{alegacy['name']}",
"checksum": alegacy.get("md5") or "",
"timestamp": ts
})
manifest_data = [
{
"guid": "12345678-1234-1234-1234-1234567890ab",
@@ -147,49 +212,36 @@ jobs:
"owner": "karol",
"category": "Playback",
"imageUrl": "",
"versions": [
{
"version": clean_ver,
"changelog": f"Automated Release {tag} (Jellyfin 12.0)",
"targetAbi": "12.0.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{tag}/BlackBarRemover_{tag}_jf12.0.zip",
"checksum": md5_10,
"timestamp": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
},
{
"version": clean_ver,
"changelog": f"Automated Release {tag} (Jellyfin 10.11)",
"targetAbi": "10.11.0.0",
"sourceUrl": f"https://gitea.labus.uk/karol/blackBarRemover/releases/download/{tag}/BlackBarRemover_{tag}_jf10.11.zip",
"checksum": md5_9,
"timestamp": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
}
]
"versions": all_versions
}
]
b64_manifest = base64.b64encode(json.dumps(manifest_data, indent=4).encode("utf-8")).decode("utf-8")
# Update on master branch
get_mf_url = f"{api_url}/repos/{repo}/contents/manifest.json?ref=master"
req_mf = urllib.request.Request(get_mf_url, headers=headers)
file_sha = None
try:
res_mf = urllib.request.urlopen(req_mf)
file_sha = json.loads(res_mf.read().decode("utf-8")).get("sha")
except Exception:
pass
# Update on master and manifest branches
for target_branch in ["master", "manifest"]:
get_mf_url = f"{api_url}/repos/{repo}/contents/manifest.json?ref={target_branch}"
req_mf = urllib.request.Request(get_mf_url, headers=headers)
file_sha = None
try:
res_mf = urllib.request.urlopen(req_mf)
file_sha = json.loads(res_mf.read().decode("utf-8")).get("sha")
except Exception:
pass
put_payload = {
"content": b64_manifest,
"message": f"Update manifest.json for {tag}",
"branch": "master"
}
if file_sha:
put_payload["sha"] = file_sha
put_payload = {
"content": b64_manifest,
"message": f"Update manifest.json for {tag}",
"branch": target_branch
}
if file_sha:
put_payload["sha"] = file_sha
put_url = f"{api_url}/repos/{repo}/contents/manifest.json"
put_req = urllib.request.Request(put_url, data=json.dumps(put_payload).encode("utf-8"), headers=headers, method="PUT")
urllib.request.urlopen(put_req)
print("manifest.json updated successfully via API.")
put_url = f"{api_url}/repos/{repo}/contents/manifest.json"
put_req = urllib.request.Request(put_url, data=json.dumps(put_payload).encode("utf-8"), headers=headers, method="PUT")
try:
urllib.request.urlopen(put_req)
print(f"manifest.json updated successfully on branch {target_branch}.")
except Exception as e:
print(f"Notice updating branch {target_branch}: {e}")
'