-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (122 loc) · 4.86 KB
/
refreshKodiAddon.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Refresh Kodi Addon Package
on:
workflow_call:
inputs:
target_app_owner:
description: "Repository name"
required: true
type: string
default: "codingPF"
target_app:
description: "Name of the addon"
required: true
type: string
default: "plugin.video.newsApp"
target_app_branch:
description: "Name of the branch"
required: true
type: string
default: "master"
target_kodi_version_name:
description: "Name of the Kodi version (e.g. matrix)"
required: true
type: string
default: "leia"
target_kodi_python_version:
description: "Name of the Kodi version (e.g. matrix)"
required: true
type: string
default: "3.0.0"
repository_package_folder:
description: "Folder which contains the packages"
required: false
type: string
default: "zips"
jobs:
refreshAddonPackage:
name: Make a new addon package
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
# checkout the repository
- name: Checkout Add-on
uses: actions/checkout@v3
with:
path: ${{ github.event.repository.name }}
ref: master
# checkout target kodi addon
- name: Checkout Add-on
uses: actions/checkout@v3
with:
path: ${{ inputs.target_app }}
repository: ${{ inputs.target_app_owner }}/${{ inputs.target_app }}
ref: ${{ inputs.target_app_branch }}
# setup VM
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libxml2-utils xmlstarlet zip
# fix py2/3
- name: Remove py2 update script for Kodi19++
if: inputs.target_kodi_python_version == '3.0.0'
run: |
rm ${{ inputs.target_app }}/mvupdate
# fix py2/3
- name: Remove py3 update script for Kodi18
if: inputs.target_kodi_python_version != '3.0.0'
run: |
rm ${{ inputs.target_app }}/mvupdate3
# create release artefacts
- name: Create Release Artefacts
run: |
SRC_PATH="${{ inputs.target_app }}"
TGT_PATH="${{ github.event.repository.name }}/${{ inputs.target_kodi_version_name }}/${{ inputs.repository_package_folder }}/${{ inputs.target_app }}"
# Remove Docker files (not needed for Kodi)
rm -r ${SRC_PATH}/docker
rm ${SRC_PATH}/Dockerfile
# remove resource folder and add new
rm -r ${TGT_PATH}/resources/*
cp -r ${SRC_PATH}/resources/*.{jpg,png} ${TGT_PATH}/resources
# fix kodi python version
xmlstarlet ed -L -u '/addon/requires/import[@addon="xbmc.python"]/@version' -v '${{ inputs.target_kodi_python_version }}' ${SRC_PATH}/addon.xml
# add addon.xml
rm ${TGT_PATH}/addon.xml
cp -r ${SRC_PATH}/addon.xml ${TGT_PATH}
# build new combined addons.xml
combindedAddonXml="${{ github.event.repository.name }}/${{ inputs.target_kodi_version_name }}/${{ inputs.repository_package_folder }}/addons.xml"
rm ${combindedAddonXml}
echo '<?xml version="1.0" encoding="utf-8"?>' > ${combindedAddonXml}
echo '<addons>' >> ${combindedAddonXml}
xmlstarlet sel -t -m '/addon' -c '/addon' ${{ github.event.repository.name }}/${{ inputs.target_kodi_version_name }}/${{ inputs.repository_package_folder }}/*/addon.xml >> ${combindedAddonXml}
echo '</addons>' >> ${combindedAddonXml}
# calc md5
md5=($(md5sum ${combindedAddonXml}))
echo $md5 > ${combindedAddonXml}.md5
# create zip file
- name: Create Zip
id: zip
run: |
# cleanup
mv .git ..
rm -rf .??*
rm *.md
# find version no
version=$(xmlstarlet sel -t -v 'string(/addon/@version)' addon.xml)
filename=${{ inputs.target_app }}-${version}.zip
# make zip
cd ..
zip -r $filename ${{ inputs.target_app }}
mv .git ${{ inputs.target_app }}
echo "filename=$filename" >> $GITHUB_OUTPUT
# copy to target release repo
cp $filename "${{ github.event.repository.name }}/${{ inputs.target_kodi_version_name }}/${{ inputs.repository_package_folder }}/${{ inputs.target_app }}"
working-directory: ${{ inputs.target_app }}
# commit into self (target kodi repository)
- name: Commit & Push changes
uses: actions-js/push@master
with:
branch: master
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: ${{ github.event.repository.name }}
message: "publish ${{ inputs.target_app }} ${{ inputs.target_app_branch }} for ${{ inputs.repository_package_folder }}"