-
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (80 loc) · 3.22 KB
/
Copy pathexport-addon.yml
File metadata and controls
90 lines (80 loc) · 3.22 KB
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
name: Export Addon to Kodi Repository
on:
workflow_dispatch: # Allow manual triggering
push:
branches: [ main ]
paths:
- 'service.libreelec.backupper/addon.xml'
- 'service.libreelec.backupper/service.py'
- 'service.libreelec.backupper/addon.py'
- 'service.libreelec.backupper/resources/**'
- '.github/workflows/export-addon.yml'
jobs:
export-addon:
runs-on: ubuntu-latest
steps:
- name: Checkout LibreELEC Backupper
uses: actions/checkout@v4
- name: Checkout Kodi Repository
uses: actions/checkout@v4
with:
repository: Nigel1992/kodi-repository
path: kodi-repo
token: ${{ secrets.REPO_PAT }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install lxml
- name: Get version and info from addon.xml
id: get_info
run: |
python3 << EOF
import os
from xml.etree import ElementTree as ET
tree = ET.parse('service.libreelec.backupper/addon.xml')
root = tree.getroot()
version = root.get('version')
description = root.find(".//description").text.strip()
news = root.find(".//news").text.strip().split('\n')[0] # Get first line of news
print(f"version={version}", file=open(os.environ['GITHUB_OUTPUT'], 'a'))
print(f"description={description}", file=open(os.environ['GITHUB_OUTPUT'], 'a'))
print(f"news={news}", file=open(os.environ['GITHUB_OUTPUT'], 'a'))
EOF
- name: Delete existing addon files
run: |
rm -rf kodi-repo/repository.nigel1992/addons/service.libreelec.backupper/*
- name: Copy addon files
run: |
cp -r service.libreelec.backupper/* kodi-repo/repository.nigel1992/addons/service.libreelec.backupper/
- name: Update Repository README
run: |
cd kodi-repo
# Update version badge in README
sed -i "s/version-.*-blue/version-${{ steps.get_info.outputs.version }}-blue/" README.md
# Update addon section
awk -v ver="${{ steps.get_info.outputs.version }}" -v desc="${{ steps.get_info.outputs.description }}" -v news="${{ steps.get_info.outputs.news }}" '
/### LibreELEC Backupper/{
print
print ""
print "**Current Version:** " ver
print ""
print desc
print ""
print "**Latest Update:** " news
print ""
getline
while($0 ~ /^[[:space:]]*$/ || $0 ~ /^Current Version/ || $0 ~ /^Latest Update/) getline
}
1' README.md > README.md.tmp && mv README.md.tmp README.md
- name: Commit and push changes
run: |
cd kodi-repo
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add repository.nigel1992/addons/service.libreelec.backupper README.md
git commit -m "Update LibreELEC Backupper to version ${{ steps.get_info.outputs.version }}"
git push