mirror of
https://github.com/metatube-community/jellyfin-plugin-metatube.git
synced 2026-02-02 18:21:48 +08:00
Chore: update manifest script (#568)
This commit is contained in:
1
.github/workflows/dotnetcore.yml
vendored
1
.github/workflows/dotnetcore.yml
vendored
@@ -33,6 +33,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate Manifest
|
- name: Generate Manifest
|
||||||
run: |
|
run: |
|
||||||
|
python3 -m pip install packaging
|
||||||
python3 scripts/manifest.py Jellyfin.Plugin.MetaTube/bin/Jellyfin.MetaTube@v${{ steps.shell.outputs.version }}.zip
|
python3 scripts/manifest.py Jellyfin.Plugin.MetaTube/bin/Jellyfin.MetaTube@v${{ steps.shell.outputs.version }}.zip
|
||||||
|
|
||||||
- name: Publish Manifest
|
- name: Publish Manifest
|
||||||
|
|||||||
@@ -1,21 +1,35 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
from packaging.version import Version
|
||||||
|
|
||||||
|
|
||||||
def md5sum(filename):
|
def md5sum(filename) -> str:
|
||||||
with open(filename, 'rb') as f:
|
with open(filename, 'rb') as f:
|
||||||
return hashlib.md5(f.read()).hexdigest()
|
return hashlib.md5(f.read()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def generate(filename, version):
|
def get_jellyfin_version(csproj: str) -> str:
|
||||||
|
tree = ET.parse(csproj)
|
||||||
|
root = tree.getroot()
|
||||||
|
|
||||||
|
for pkg in root.iter("PackageReference"):
|
||||||
|
if pkg.attrib.get("Include") in ("Jellyfin.Controller", "Jellyfin.Model"):
|
||||||
|
return Version(pkg.attrib.get("Version")).base_version
|
||||||
|
|
||||||
|
raise Exception("Jellyfin version not found")
|
||||||
|
|
||||||
|
|
||||||
|
def generate(filename, version, csproj) -> dict:
|
||||||
return {
|
return {
|
||||||
'checksum': md5sum(filename),
|
'checksum': md5sum(filename),
|
||||||
'changelog': 'Auto Released by Actions',
|
'changelog': 'Auto Released by Actions',
|
||||||
'targetAbi': '10.9.0.0',
|
'targetAbi': f'{get_jellyfin_version(csproj)}.0',
|
||||||
'sourceUrl': 'https://github.com/metatube-community/jellyfin-plugin-metatube/releases/download/'
|
'sourceUrl': 'https://github.com/metatube-community/jellyfin-plugin-metatube/releases/download/'
|
||||||
f'v{version}/Jellyfin.MetaTube@v{version}.zip',
|
f'v{version}/Jellyfin.MetaTube@v{version}.zip',
|
||||||
'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ'),
|
'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ'),
|
||||||
@@ -23,16 +37,20 @@ def generate(filename, version):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
version = filename.split('@', maxsplit=1)[1] \
|
version = filename.split('@', maxsplit=1)[1] \
|
||||||
.removeprefix('v') \
|
.removeprefix('v') \
|
||||||
.removesuffix('.zip')
|
.removesuffix('.zip')
|
||||||
|
|
||||||
with urlopen('https://raw.githubusercontent.com/metatube-community/jellyfin-plugin-metatube/dist/manifest.json') as f:
|
csproj = os.path.join(os.path.dirname(__file__),
|
||||||
|
"../Jellyfin.Plugin.MetaTube/Jellyfin.Plugin.MetaTube.csproj")
|
||||||
|
|
||||||
|
with urlopen(
|
||||||
|
'https://raw.githubusercontent.com/metatube-community/jellyfin-plugin-metatube/dist/manifest.json') as f:
|
||||||
manifest = json.load(f)
|
manifest = json.load(f)
|
||||||
|
|
||||||
manifest[0]['versions'].insert(0, generate(filename, version))
|
manifest[0]['versions'].insert(0, generate(filename, version, csproj))
|
||||||
|
|
||||||
with open('manifest.json', 'w') as f:
|
with open('manifest.json', 'w') as f:
|
||||||
json.dump(manifest, f, indent=2)
|
json.dump(manifest, f, indent=2)
|
||||||
|
|||||||
Reference in New Issue
Block a user