Debian Codegraph @

release.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 import subprocess
3 import re
4
5 # print changelog
6 current_tag = subprocess.run(
7 ['git', 'describe', '--tags', '--abbrev=0'], capture_output=True, text=True).stdout.strip()
8 if current_tag == "":
9 # os.system("git log HEAD --oneline")
10 interval = 'HEAD'
11 else:
12 print("current tag: %s" % current_tag)
13 interval = '%s..HEAD' % current_tag
14
15 print("CHANGELOG:\n\n%s\n" % subprocess.run(
16 ['git', 'log', interval, '--oneline'], capture_output=True, text=True).stdout.strip())
17
18 version_match_re = r'Version\s*=\s*"([^"]+)"'
19
20 with open('core/banner.go', 'rt') as fp:
21 banner = fp.read()
22
23 # parse current version and get next from user
24 m = re.findall(version_match_re, banner, re.MULTILINE)
25 if len(m) != 1:
26 print("could not parse current version from core/banner.go")
27 quit()
28
29 current_ver = m[0]
30 next_ver = input("current version is %s, enter next: " % current_ver)
31
32 # generate new manifest
33 result = re.sub(version_match_re, 'Version = "%s"' %
34 next_ver, banner, 0, re.MULTILINE)
35 with open('core/banner.go', 'w+t') as fp:
36 fp.write(result)
37
38 # commit, push and create new tag
39 print("git add core/banner.go")
40 print("git commit -m 'releasing version %s'" % next_ver)
41 print("git push")
42 print("git tag -a v%s -m 'releasing v%s'" % (next_ver, next_ver))
43 print("git push origin v%s" % next_ver)