File size: 645 Bytes
4a51346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import argparse
import re
import subprocess

version_pattern = r'\d\.\d\.\d'
parser = argparse.ArgumentParser()
parser.add_argument('version', help='a SEMVER string X.Y.Z')
args = parser.parse_args()
if not re.match(version_pattern, args.version):
    print('argument must be SEMVER string in format X.Y.Z')
else:
    with open('setup.py') as fp:
        old_setupfile = fp.read()
    new_setupfile = re.sub(f"version='{version_pattern}'",
                           f"version='{args.version}'", old_setupfile)
    with open('setup.py', 'w') as fp:
        print(new_setupfile, file=fp)

    subprocess.run(['./publish.sh', 'v' + args.version])