-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_release.py
44 lines (37 loc) · 1.22 KB
/
update_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
import os
import re
def update_sk_version(release):
version_file = 'skvalidate/__init__.py'
with open(version_file) as f:
content = f.readlines()
pattern = "(\d+\.)?(\d+\.)?(\*|\d+)"
for i, line in enumerate(content):
if line.startswith('__version__'):
line = re.sub(pattern, release, line)
content[i] = line
break
content = ''.join(content)
with open(version_file, 'w') as f:
f.write(content)
def update_changelog(release):
input_file = 'CHANGELOG.md'
with open(input_file) as f:
content = f.read()
content = content.replace('Unreleased', 'v' + release)
content = content.replace('HEAD', 'v' + release)
with open(input_file, 'w+') as f:
f.write(content)
def update_history(release):
input_file = 'HISTORY.rst'
with open(input_file) as f:
content = f.read()
content = content.replace('(unreleased)', release)
# fixes
content = content.replace('"sv_"', '"sv\_"')
with open(input_file, 'w+') as f:
f.write(content)
if __name__ == '__main__':
release = os.environ.get('RELEASE', 'unreleased')
update_sk_version(release)
update_changelog(release)
update_history(release)