mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 03:52:51 +01:00
Release script: datestamp and version commands
This commit is contained in:
parent
6ecf4ef6ed
commit
dd11795cbd
2 changed files with 49 additions and 2 deletions
|
|
@ -1,8 +1,8 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
1.3.6 (in development)
|
||||
----------------------
|
||||
1.3.6 (May 7, 2014)
|
||||
-------------------
|
||||
|
||||
* The new :doc:`/plugins/play` lets you start your desktop music player with
|
||||
the songs that match a query. Thanks to David Hamp-Gonsalves.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
from contextlib import contextmanager
|
||||
import datetime
|
||||
|
||||
BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
CHANGELOG = os.path.join(BASE, 'docs', 'changelog.rst')
|
||||
|
|
@ -200,5 +201,51 @@ def upload(version):
|
|||
subprocess.check_call(['twine', 'upload', path])
|
||||
|
||||
|
||||
def get_version():
|
||||
"""Read the current version from the changelog.
|
||||
"""
|
||||
with open(CHANGELOG) as f:
|
||||
for line in f:
|
||||
match = re.search(r'\d+\.\d+\.\d+', line)
|
||||
if match:
|
||||
return match.group(0)
|
||||
|
||||
|
||||
@release.command()
|
||||
def version():
|
||||
"""Display the current version.
|
||||
"""
|
||||
print(get_version())
|
||||
|
||||
|
||||
@release.command()
|
||||
def datestamp():
|
||||
"""Enter today's date as the release date in the changelog.
|
||||
"""
|
||||
dt = datetime.datetime.now()
|
||||
stamp = '({} {}, {})'.format(dt.strftime('%B'), dt.day, dt.year)
|
||||
marker = '(in development)'
|
||||
|
||||
lines = []
|
||||
underline_length = None
|
||||
with open(CHANGELOG) as f:
|
||||
for line in f:
|
||||
if marker in line:
|
||||
# The header line.
|
||||
line = line.replace(marker, stamp)
|
||||
lines.append(line)
|
||||
underline_length = len(line.strip())
|
||||
elif underline_length:
|
||||
# This is the line after the header. Rewrite the dashes.
|
||||
lines.append('-' * underline_length + '\n')
|
||||
underline_length = None
|
||||
else:
|
||||
lines.append(line)
|
||||
|
||||
with open(CHANGELOG, 'w') as f:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
release()
|
||||
|
|
|
|||
Loading…
Reference in a new issue