mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-13 17:27:16 +08:00
release: Add the changelog for the current version to the json file and to the atom feed
This commit is contained in:
parent
41aa1cb603
commit
87e8c5ea88
29
devscripts/extract-changes.py
Executable file
29
devscripts/extract-changes.py
Executable file
@ -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))
|
||||
|
@ -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
|
||||
|
||||
|
@ -5,6 +5,7 @@ import datetime
|
||||
import textwrap
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
atom_template=textwrap.dedent("""\
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
@ -22,7 +23,8 @@ entry_template=textwrap.dedent("""
|
||||
<atom:link href="http://rg3.github.io/youtube-dl" />
|
||||
<atom:content type="xhtml">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||
Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a>
|
||||
<p>Downloads available at <a href="https://yt-dl.org/downloads/@VERSION@/">https://yt-dl.org/downloads/@VERSION@/</a></p>
|
||||
<p>@CHANGES@</p>
|
||||
</div>
|
||||
</atom:content>
|
||||
<atom:author>
|
||||
@ -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')
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user