From f5d27862d616c8f8d987ed6293483a42ac75a889 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 18 Jul 2020 01:15:08 -0400 Subject: [PATCH 1/6] 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 From 54d9187e778caa5a0784429314f1f8f0e105fd9f Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 18 Jul 2020 01:18:44 -0400 Subject: [PATCH 2/6] Uncomment file transfers --- .ci/build.yml | 28 ++++++++++++++-------------- .config/template.xml | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.ci/build.yml b/.ci/build.yml index c7f3910d..4b74f272 100644 --- a/.ci/build.yml +++ b/.ci/build.yml @@ -22,17 +22,17 @@ steps: - 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 }' + - 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/template.xml b/.config/template.xml index 1fd6e1ee..ee6bb514 100644 --- a/.config/template.xml +++ b/.config/template.xml @@ -1,7 +1,7 @@ From 1f5901d2ba75f8527b943846012c211a8d1ec7ea Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 7 Aug 2020 10:54:55 -0400 Subject: [PATCH 3/6] Add conditions and use ArchiveFile task --- .ci/build.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.ci/build.yml b/.ci/build.yml index 4b74f272..87a0aff6 100644 --- a/.ci/build.yml +++ b/.ci/build.yml @@ -16,23 +16,28 @@ steps: - 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 + - task: ArchiveFiles@2 displayName: 'Create ${{ py_version }} zip file' - - - script: ls . - displayName: 'home dir 2' + inputs: + rootFolderOrFile: jellyfin-kodi + includeRootFolder: False + archiveType: 'zip' + tarCompression: 'none' + archiveFile: 'plugin.video.jellyfin-${{ py_version }}.zip' - task: CopyFilesOverSSH@0 displayName: 'Upload to repo server' inputs: sshEndpoint: repository sourceFolder: '${Agent.BuildDirectory}' - contents: 'plugin.video.jellyfin*' + contents: 'plugin.video.jellyfin-${{ py-version }}.zip' targetFolder: '/srv/repository/incoming/kodi' + condition: startsWith(variables['Build.SourceBranch'], 'refs/tags') - 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 }' + inline: 'python3 /usr/local/bin/kodirepo add /srv/repository/incoming/kodi/plugin.video.jellyfin-${{ py_version }} --datadir /srv/repository/releases/client/kodi/${{ py_version }}' + condition: startsWith(variables['Build.SourceBranch'], 'refs/tags') From d839b3a60a50c08b0e561ede2822a0bc1016db37 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 7 Aug 2020 11:26:51 -0400 Subject: [PATCH 4/6] Use command instead of inline for repo command --- .ci/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/build.yml b/.ci/build.yml index 87a0aff6..cc8f60a0 100644 --- a/.ci/build.yml +++ b/.ci/build.yml @@ -38,6 +38,6 @@ steps: displayName: 'Add to Kodi repo' inputs: sshEndpoint: repository - runOptions: 'inline' - inline: 'python3 /usr/local/bin/kodirepo add /srv/repository/incoming/kodi/plugin.video.jellyfin-${{ py_version }} --datadir /srv/repository/releases/client/kodi/${{ py_version }}' + runOptions: 'commands' + commands: 'sudo -n python3 /usr/local/bin/kodirepo add /srv/repository/incoming/kodi/plugin.video.jellyfin-${{ py_version }} --datadir /srv/repository/releases/client/kodi/${{ py_version }}' condition: startsWith(variables['Build.SourceBranch'], 'refs/tags') From 564982919dcbcbfff0176af0758daadae7d50f4d Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 7 Aug 2020 14:51:03 -0400 Subject: [PATCH 5/6] Include version/date in changelog --- .config/generate_xml.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/generate_xml.py b/.config/generate_xml.py index 386cae57..a51c4241 100644 --- a/.config/generate_xml.py +++ b/.config/generate_xml.py @@ -2,6 +2,7 @@ import xml.etree.ElementTree as ET import yaml import sys import os +from datetime import datetime def indent(elem, level=0): ''' @@ -52,11 +53,12 @@ addon_version = data.get('version') root.attrib['version'] = f'{addon_version}-{py_version}' # Changelog +date = datetime.today().strftime('%Y-%m-%d') changelog = data.get('changelog') for section in root.findall('extension'): news = section.findall('news') if news: - news[0].text = f'Changelog:\n{changelog}' + news[0].text = f'v{addon_version} ({date}):\n{changelog}' # Format xml tree indent(root) From 6af4cfc05f507ede93c945aad61d92fb01149b56 Mon Sep 17 00:00:00 2001 From: mcarlton00 Date: Sat, 8 Aug 2020 18:45:54 -0400 Subject: [PATCH 6/6] Update .config/generate_xml.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Odd Stråbø --- .config/generate_xml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/generate_xml.py b/.config/generate_xml.py index a51c4241..a35b995e 100644 --- a/.config/generate_xml.py +++ b/.config/generate_xml.py @@ -50,7 +50,7 @@ for dep in deps: # Update version string addon_version = data.get('version') -root.attrib['version'] = f'{addon_version}-{py_version}' +root.attrib['version'] = f'{addon_version}+{py_version}' # Changelog date = datetime.today().strftime('%Y-%m-%d')