-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrelease.py
46 lines (36 loc) · 1.55 KB
/
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
#!/usr/bin/env python3
import changelog # Our own changelog.py
import fileinput
import subprocess
import sys
if not len(sys.argv) > 1:
print('Needs new version number provided as argument')
exit()
version = sys.argv[1]
if version[0] == "v":
print('Please omit the "v" prefix. The script will add it')
exit()
tocs = ['ExtendedCharacterStats-Classic.toc', 'ExtendedCharacterStats-BCC.toc', 'ExtendedCharacterStats-WOTLKC.toc']
for toc in tocs:
with fileinput.FileInput(toc, inplace=True) as file:
for line in file:
if line[:10] == '## Version':
print('## Version: ' + version)
elif line[:8] == '## Title':
print('## Title: Extended Character Stats v' + version)
else:
print(line, end='')
with fileinput.FileInput('README.md', inplace=True) as file:
for line in file:
if line[:20] == '[![Downloads Latest]':
print('[![Downloads Latest](https://img.shields.io/github/downloads/BreakBB/ExtendedCharacterStats/v' + version + '/total.svg)](https://github.com/BreakBB/ExtendedCharacterStats/releases/latest)')
else:
print(line, end='')
changelogString = changelog.get_commit_changelog()
print('######### START CHANGELOG')
print('# ExtendedCharacterStats v' + version + '\n\n' + changelogString)
print('######### END CHANGELOG')
subprocess.run(['git', 'add', 'README.md'])
subprocess.run(['git', 'add', '*.toc'])
subprocess.run(['git', 'commit', '-mBump version to v' + version])
subprocess.run(['git', 'tag', 'v' + version])