mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
Merge pull request #585 from oddstr13/ci/reformat-changelog
Improve changelog formatting
This commit is contained in:
commit
d9f3452c10
4 changed files with 115 additions and 9 deletions
87
.github/tools/reformat_changelog.py
vendored
Executable file
87
.github/tools/reformat_changelog.py
vendored
Executable file
|
@ -0,0 +1,87 @@
|
||||||
|
#!/usr/bin/env python3.8
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
from typing import Dict, List, Pattern, Union, TypedDict
|
||||||
|
|
||||||
|
from emoji.core import emojize, demojize, replace_emoji
|
||||||
|
|
||||||
|
|
||||||
|
ITEM_FORMAT = "+ {title} (#{issue}) @{username}"
|
||||||
|
OUTPUT_EMOJI = False
|
||||||
|
|
||||||
|
ITEM_PATTERN: Pattern = re.compile(
|
||||||
|
r"^\s*(?P<old_listchar>[-*+])\s*(?P<title>.*?)\s*\(#(?P<issue>[0-9]+)\)\s*@(?P<username>[^\s]*)$"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SectionType(TypedDict):
|
||||||
|
title: str
|
||||||
|
items: List[Dict[str, str]]
|
||||||
|
|
||||||
|
|
||||||
|
def reformat(item_format: str, output_emoji: bool) -> None:
|
||||||
|
data = [
|
||||||
|
emojize(x.strip(), use_aliases=True, variant="emoji_type")
|
||||||
|
for x in sys.stdin.readlines()
|
||||||
|
if x.strip()
|
||||||
|
]
|
||||||
|
|
||||||
|
sections = []
|
||||||
|
|
||||||
|
section: Union[SectionType, Dict] = {}
|
||||||
|
for line in data:
|
||||||
|
if line.startswith("## "):
|
||||||
|
pass
|
||||||
|
if line.startswith("### "):
|
||||||
|
if section:
|
||||||
|
sections.append(section)
|
||||||
|
_section: SectionType = {
|
||||||
|
"title": line.strip("# "),
|
||||||
|
"items": [],
|
||||||
|
}
|
||||||
|
section = _section
|
||||||
|
|
||||||
|
m = ITEM_PATTERN.match(line)
|
||||||
|
if m:
|
||||||
|
gd = m.groupdict()
|
||||||
|
section["items"].append(gd)
|
||||||
|
|
||||||
|
sections.append(section)
|
||||||
|
|
||||||
|
first = True
|
||||||
|
|
||||||
|
for section in sections:
|
||||||
|
if not section:
|
||||||
|
continue
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
|
||||||
|
title = section["title"]
|
||||||
|
if not output_emoji:
|
||||||
|
title = replace_emoji(title).strip()
|
||||||
|
|
||||||
|
print(title)
|
||||||
|
print("-" * len(title))
|
||||||
|
|
||||||
|
for item in section["items"]:
|
||||||
|
formatted_item = item_format.format(**item)
|
||||||
|
if not output_emoji:
|
||||||
|
formatted_item = demojize(formatted_item)
|
||||||
|
print(formatted_item)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--format", type=str, default=ITEM_FORMAT)
|
||||||
|
|
||||||
|
parser.add_argument("--no-emoji", dest="emoji", action="store_false")
|
||||||
|
parser.add_argument("--emoji", dest="emoji", action="store_true")
|
||||||
|
parser.set_defaults(emoji=OUTPUT_EMOJI)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
reformat(args.format, args.emoji)
|
|
@ -22,14 +22,17 @@ jobs:
|
||||||
|
|
||||||
- name: Parse Changlog
|
- name: Parse Changlog
|
||||||
run: |
|
run: |
|
||||||
|
pip install emoji
|
||||||
cat << EOF >> cl.md
|
cat << EOF >> cl.md
|
||||||
${{ steps.draft.outputs.body }}
|
${{ steps.draft.outputs.body }}
|
||||||
EOF
|
EOF
|
||||||
sed -i cl.md -e 's/^*/-/'
|
|
||||||
TAG="${{ steps.draft.outputs.tag_name }}"
|
TAG="${{ steps.draft.outputs.tag_name }}"
|
||||||
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
|
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
|
||||||
|
echo "YAML_CHANGELOG<<EOF" >> $GITHUB_ENV
|
||||||
|
cat cl.md | python .github/tools/reformat_changelog.py --no-emoji >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
|
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
|
||||||
cat cl.md | grep '^-' >> $GITHUB_ENV
|
cat cl.md | python .github/tools/reformat_changelog.py --emoji --format='+ #{issue} by @{username}' >> $GITHUB_ENV
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
rm cl.md
|
rm cl.md
|
||||||
|
|
||||||
|
@ -38,7 +41,7 @@ jobs:
|
||||||
|
|
||||||
- name: Update release.yaml
|
- name: Update release.yaml
|
||||||
run: |
|
run: |
|
||||||
yq eval '.version = env(VERSION) | .changelog = strenv(CHANGELOG) | .changelog style="literal"' -i release.yaml
|
yq eval '.version = env(VERSION) | .changelog = strenv(YAML_CHANGELOG) | .changelog style="literal"' -i release.yaml
|
||||||
|
|
||||||
- name: Commit Changes
|
- name: Commit Changes
|
||||||
run: |
|
run: |
|
||||||
|
|
26
build.py
26
build.py
|
@ -82,17 +82,33 @@ def file_filter(file_name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
True if file_name is meant to be included
|
True if file_name is meant to be included
|
||||||
"""
|
"""
|
||||||
return 'plugin.video.jellyfin' not in file_name and 'pyo' not in file_name
|
return (
|
||||||
|
not (file_name.startswith('plugin.video.jellyfin') and file_name.endswith('.zip'))
|
||||||
|
and not file_name.endswith('.pyo')
|
||||||
|
and not file_name.endswith('.pyc')
|
||||||
|
and not file_name.endswith('.pyd')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def folder_filter(folder_name: str) -> bool:
|
def folder_filter(folder_name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
True if folder_name is meant to be included
|
True if folder_name is meant to be included
|
||||||
"""
|
"""
|
||||||
return ('.ci' not in folder_name
|
filters = [
|
||||||
and '.git' not in folder_name
|
'.ci',
|
||||||
and '.github' not in folder_name
|
'.git',
|
||||||
and '.build' not in folder_name)
|
'.github',
|
||||||
|
'.build',
|
||||||
|
'.mypy_cache',
|
||||||
|
'.pytest_cache',
|
||||||
|
'__pycache__',
|
||||||
|
]
|
||||||
|
for f in filters:
|
||||||
|
if f in folder_name.split(os.path.sep):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -1,7 +1,7 @@
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 9999
|
max-line-length = 9999
|
||||||
import-order-style = pep8
|
import-order-style = pep8
|
||||||
exclude = .git,.vscode,libraries,build.py
|
exclude = .git,.vscode,libraries,build.py,.github
|
||||||
extend-ignore =
|
extend-ignore =
|
||||||
I202
|
I202
|
||||||
per-file-ignores =
|
per-file-ignores =
|
||||||
|
|
Loading…
Reference in a new issue