| 1 |
|
| 2 |
import subprocess |
| 3 |
import re |
| 4 |
|
| 5 |
|
| 6 |
current_tag = subprocess.run( |
| 7 |
['git', 'describe', '--tags', '--abbrev=0'], capture_output=True, text=True).stdout.strip() |
| 8 |
if current_tag == "": |
| 9 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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) |