forked from liam2/liam2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
next_release.py
47 lines (36 loc) · 1.32 KB
/
next_release.py
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
#!/usr/bin/python
# encoding: utf-8
# script to start a new release cycle
# Licence: GPLv3
from os.path import join
from make_release import relname2fname, short, long_release_name
from shutil import copy
def add_release(release_name):
release_name = long_release_name(release_name)
fname = relname2fname(release_name)
# create "empty" changelog for that release
changes_dir = r'doc\usersguide\source\changes'
copy(join(changes_dir, 'template.rst.inc'),
join(changes_dir, fname))
# include release changelog in changes.rst
fpath = r'doc\usersguide\source\changes.rst'
changelog_template = """{title}
{underline}
In development.
.. include:: {fpath}
"""
with open(fpath) as f:
lines = f.readlines()
title = "Version %s" % short(release_name)
if lines[5] == title + '\n':
print("changes.rst not modified (it already contains %s)" % title)
return
this_version = changelog_template.format(title=title,
underline="=" * len(title),
fpath='changes/' + fname)
lines[5:5] = this_version.splitlines(True)
with open(fpath, 'w') as f:
f.writelines(lines)
if __name__ == '__main__':
from sys import argv
add_release(*argv[1:])