From f5d27862d616c8f8d987ed6293483a42ac75a889 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 18 Jul 2020 01:15:08 -0400 Subject: [PATCH] Azure pipeline + revamp release process --- .ci/azure-pipelines.yml | 9 +++++ .ci/build.yml | 38 ++++++++++++++++++ .config/generate_xml.py | 65 +++++++++++++++++++++++++++++++ .config/py2.yaml | 14 +++++++ .config/py3.yaml | 12 ++++++ addon.xml => .config/template.xml | 11 +----- .gitignore | 1 + release.yaml | 3 ++ 8 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 .ci/azure-pipelines.yml create mode 100644 .ci/build.yml create mode 100644 .config/generate_xml.py create mode 100644 .config/py2.yaml create mode 100644 .config/py3.yaml rename addon.xml => .config/template.xml (82%) create mode 100644 release.yaml diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml new file mode 100644 index 00000000..754303a7 --- /dev/null +++ b/.ci/azure-pipelines.yml @@ -0,0 +1,9 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +steps: + - template: build.yml + parameters: + py_versions: [ 'py2', 'py3' ] diff --git a/.ci/build.yml b/.ci/build.yml new file mode 100644 index 00000000..c7f3910d --- /dev/null +++ b/.ci/build.yml @@ -0,0 +1,38 @@ +parameters: + python_versions : [] + +steps: + - ${{ each py_version in parameters.py_versions }}: + - task: usePythonVersion@0 + inputs: + versionSpec: '3.6' + + - checkout: self + clean: true + + - script: python3 -m pip install --user pyyaml + displayName: 'Install PyYaml' + + - script: python3 jellyfin-kodi/.config/generate_xml.py ${{ py_version }} + displayName: 'Create ${{ py_version }} addon.xml' + + - script: zip -r plugin.video.jellyfin-${{ py_version }}.zip jellyfin-kodi + displayName: 'Create ${{ py_version }} zip file' + + - script: ls . + displayName: 'home dir 2' + +# - task: CopyFilesOverSSH@0 +# displayName: 'Upload to repo server' +# inputs: +# sshEndpoint: repository +# sourceFolder: '${Agent.BuildDirectory}' +# contents: 'plugin.video.jellyfin*' +# targetFolder: '/srv/repository/incoming/kodi' +# +# - task: SSH@0 +# displayName: 'Add to Kodi repo' +# inputs: +# sshEndpoint: repository +# runOptions: 'inline' +# inline: 'python3 /usr/local/bin/kodirepo add /srv/repository/incoming/kodi/plugin.video.jellyfin-version-${ py_version } --datadir /srv/repository/releases/client/kodi/${ py_version }' diff --git a/.config/generate_xml.py b/.config/generate_xml.py new file mode 100644 index 00000000..386cae57 --- /dev/null +++ b/.config/generate_xml.py @@ -0,0 +1,65 @@ +import xml.etree.ElementTree as ET +import yaml +import sys +import os + +def indent(elem, level=0): + ''' + Nicely formats output xml with newlines and spaces + https://stackoverflow.com/a/33956544 + ''' + i = "\n" + level*" " + if len(elem): + if not elem.text or not elem.text.strip(): + elem.text = i + " " + if not elem.tail or not elem.tail.strip(): + elem.tail = i + for elem in elem: + indent(elem, level+1) + if not elem.tail or not elem.tail.strip(): + elem.tail = i + else: + if level and (not elem.tail or not elem.tail.strip()): + elem.tail = i + +try: + py_version = sys.argv[1] +except IndexError: + print('No version specified') + sys.exit(1) + +dir_path = os.path.dirname(os.path.realpath(__file__)) + +# Load template file +with open(f'{dir_path}/template.xml', 'r') as f: + tree = ET.parse(f) + root = tree.getroot() + +# Load version dependencies +with open(f'{dir_path}/{py_version}.yaml', 'r') as f: + deps = yaml.safe_load(f) + +# Load version and changelog +with open('jellyfin-kodi/release.yaml', 'r') as f: + data = yaml.safe_load(f) + +# Populate xml template +for dep in deps: + ET.SubElement(root.find('requires'), 'import', attrib=dep) + +# Update version string +addon_version = data.get('version') +root.attrib['version'] = f'{addon_version}-{py_version}' + +# Changelog +changelog = data.get('changelog') +for section in root.findall('extension'): + news = section.findall('news') + if news: + news[0].text = f'Changelog:\n{changelog}' + +# Format xml tree +indent(root) + +# Write addon.xml +tree.write('jellyfin-kodi/addon.xml', encoding='utf-8', xml_declaration=True) diff --git a/.config/py2.yaml b/.config/py2.yaml new file mode 100644 index 00000000..f673c810 --- /dev/null +++ b/.config/py2.yaml @@ -0,0 +1,14 @@ +- addon: 'xbmc.python' + version: '2.25.0' +- addon: 'script.module.requests' + version: '2.22.0' +- addon: 'script.module.dateutil' + version: '2.8.1' +- addon: 'script.module.six' + version: '1.13.0' +- addon: 'script.module.kodi-six' + version: '0.0.7' +- addon: 'script.module.addon.signals' + version: '0.0.5' +- addon: 'script.module.futures' + version: '2.2.0' diff --git a/.config/py3.yaml b/.config/py3.yaml new file mode 100644 index 00000000..83d2d87f --- /dev/null +++ b/.config/py3.yaml @@ -0,0 +1,12 @@ +- addon: 'xbmc.python' + version: '3.0.0' +- addon: 'script.module.requests' + version: '2.22.0+matrix.1' +- addon: 'script.module.dateutil' + version: '2.8.1+matrix.1' +- addon: 'script.module.six' + version: '1.14.0+matrix.2' +- addon: 'script.module.kodi-six' + version: '0.1.3+1' +- addon: 'script.module.addon.signals' + version: '0.0.5+matrix.1' diff --git a/addon.xml b/.config/template.xml similarity index 82% rename from addon.xml rename to .config/template.xml index a5deaed0..1fd6e1ee 100644 --- a/addon.xml +++ b/.config/template.xml @@ -4,13 +4,6 @@ version="0.5.8" provider-name="Jellyfin Contributors, angelblue05"> - - - - - - - @@ -35,13 +28,11 @@ en GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007 https://forum.jellyfin.org - https://jellyfin.media/ + https://jellyfin.org/ https://github.com/jellyfin/jellyfin-kodi Welcome to Jellyfin for Kodi! A whole new way to manage and view your media library. The Jellyfin addon for Kodi combines the best of Kodi - ultra smooth navigation, beautiful UIs and playback of any file under the sun, and Jellyfin - the most powerful fully open source multi-client media metadata indexer and server. Jellyfin for Kodi is the absolute best way to enjoy the incredible Kodi playback engine combined with the power of Jellyfin's centralized database. Features: * Direct integration with the Kodi library for native Kodi speed * Instant synchronization with the Jellyfin server * Full support for Movie, TV and Music collections * Jellyfin Server direct stream and transcoding support - use Kodi when you are away from home! - v0.5.8 (2020-06-15) - #322 Force filter parameter during incremental sync resources/icon.png diff --git a/.gitignore b/.gitignore index c79bce8b..8e87645e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ machine_guid .vscode/ pyinstrument/ pyinstrument_cext.so +addon.xml diff --git a/release.yaml b/release.yaml new file mode 100644 index 00000000..432f05d3 --- /dev/null +++ b/release.yaml @@ -0,0 +1,3 @@ +version: '0.5.8' +changelog: | + #322 Force filter parameter during incremental sync