forked from rendaw/trezor-gpg-pinentry-tk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish.py
executable file
·31 lines (30 loc) · 1.17 KB
/
publish.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
#!/usr/bin/env python3
import subprocess
import argparse
import re
parser = argparse.ArgumentParser()
parser.add_argument('version')
parser.add_argument('-f', '--force', action='store_true')
args = parser.parse_args()
if not args.force and subprocess.call(['git', 'diff-index', '--quiet', 'HEAD']) != 0: # noqa
raise RuntimeError('Working directory must be clean.')
if not re.match('\\d+\\.\\d+\\.\\d+', args.version):
args.error('version must be in the format N.N.N')
with open('setup.py', 'r') as source:
oldsetup = source.read()
with open('setup.py', 'w') as dest:
dest.write(re.sub(
'^GEN_version = .*$',
'GEN_version = \'{}\''.format(args.version),
oldsetup,
flags=re.M))
subprocess.check_call([
'git', 'commit', 'setup.py', '--allow-empty', '-m', 'Version {}'.format(
args.version)
])
subprocess.check_call(['git', 'tag', 'v{}'.format(args.version)])
subprocess.check_call(['git', 'push'])
subprocess.check_call(['git', 'push', '--tags'])
subprocess.check_call(['python', 'setup.py', 'sdist'])
dist = 'dist/trezor-gpg-pinentry-tk-{}.tar.gz'.format(args.version)
subprocess.check_call(['twine', 'upload', dist, '--user', 'rendaw'])