diff --git a/devscripts/extract-changes.py b/devscripts/extract-changes.py new file mode 100755 index 000000000..430132d08 --- /dev/null +++ b/devscripts/extract-changes.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +import sys +import json + +target_version = sys.argv[1] + +def empty_doc(): + return [{"unMeta":{}}, []] + +doc = json.loads(input()) +body = doc[1] + + +# We get the text for each version +versions = {} +current_version = None +for el in body: + el.keys() + type_ = list(el.keys())[0] + if type_ == 'Header': + current_version = el['Header'][2][0]['Str'] + versions[current_version] = empty_doc() + elif current_version is not None: + versions[current_version][1].append(el) + +# We get the document for the target version and create the json string for pandoc +version_changelog = versions.get(target_version, empty_doc()) +print(json.dumps(version_changelog)) + diff --git a/devscripts/gh-pages/add-version.py b/devscripts/gh-pages/add-version.py index 35865b2f3..8b4b81d06 100755 --- a/devscripts/gh-pages/add-version.py +++ b/devscripts/gh-pages/add-version.py @@ -5,7 +5,6 @@ import sys import hashlib import os.path - if len(sys.argv) <= 1: print('Specify the version number as parameter') sys.exit() @@ -35,6 +34,11 @@ for key, filename in filenames.items(): sha256sum = hashlib.sha256(data).hexdigest() new_version[key] = (url, sha256sum) +with open(os.path.join(build_dir, 'CHANGELOG.md'), 'rt') as f: + changes = f.read().strip() + if changes: + new_version['changelog'] = changes + versions_info['versions'][version] = new_version versions_info['latest'] = version diff --git a/devscripts/gh-pages/update-feed.py b/devscripts/gh-pages/update-feed.py index 16571a924..bb671e054 100755 --- a/devscripts/gh-pages/update-feed.py +++ b/devscripts/gh-pages/update-feed.py @@ -5,6 +5,7 @@ import datetime import textwrap import json +import subprocess atom_template=textwrap.dedent("""\ @@ -22,7 +23,8 @@ entry_template=textwrap.dedent(""" - Downloads available at https://yt-dl.org/downloads/@VERSION@/ + Downloads available at https://yt-dl.org/downloads/@VERSION@/ + @CHANGES@ @@ -46,6 +48,14 @@ versions.sort() for v in versions: entry = entry_template.replace('@TIMESTAMP@',v.replace('.','-')) entry = entry.replace('@VERSION@',v) + changes = versions_info['versions'][v].get('changelog', '') + if changes: + # We only convert the changelog to html with pandoc if it's not an empty string + pandoc_cmd = ['pandoc', '--from', 'markdown', '--to', 'html'] + pandoc = subprocess.Popen(pandoc_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + changes = pandoc.communicate(input=changes.encode('utf-8'))[0].decode('utf-8') + changes = u'Changelog: {}'.format(changes) + entry = entry.replace('@CHANGES@', changes) entries.append(entry) entries_str = textwrap.indent(''.join(entries), '\t') diff --git a/devscripts/release.sh b/devscripts/release.sh index c38b0259a..123b44163 100755 --- a/devscripts/release.sh +++ b/devscripts/release.sh @@ -74,6 +74,9 @@ scp -r "build/$version" ytdl@yt-dl.org:html/tmp/ ssh ytdl@yt-dl.org "mv html/tmp/$version html/downloads/" ssh ytdl@yt-dl.org "sh html/update_latest.sh $version" +echo -e "\n### Generating changelog" +pandoc CHANGELOG.md -t json | ./devscripts/extract-changes.py ${version} | pandoc -f json -o build/$version/CHANGELOG.md + /bin/echo -e "\n### Now switching to gh-pages..." git clone --branch gh-pages --single-branch . build/gh-pages ROOT=$(pwd)
Downloads available at https://yt-dl.org/downloads/@VERSION@/
@CHANGES@