Skip to content

Commit

Permalink
Refine release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Jul 23, 2023
1 parent 6f018f7 commit 77941ef
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,37 @@ def main():
adhf = argparse.ArgumentDefaultsHelpFormatter
ap = argparse.ArgumentParser(formatter_class=adhf, prog=fn)
aa = ap.add_argument
aa('--upload', default=False, action='store_true', help='Upload to PyPI')
aa('-b', '--build', default=False, action='store_true', help='Force a rebuild')
aa('-u', '--upload', default=False, action='store_true', help='Upload to PyPI')
options = ap.parse_args()
with open('gnupg.py') as f:
data = f.read()
m = re.search(r"__version__\s*=\s*'(.*)'", data)
assert m
ver = m.groups()[0]
sigs = list(glob.glob(f'dist/*{ver}*.asc'))
if sigs:
# import pdb; pdb.set_trace()
if sigs and not options.build:
print(f'Signatures found: {", ".join(sigs)}')
else:
print('Signatures not found ...')
files = list(glob.glob(f'dist/*{ver}*'))
if files:
if not sigs:
print('Signatures not found ...')
files = [fn for fn in glob.glob(f'dist/*{ver}*') if not fn.endswith('.asc')]
if files and not options.build:
print(f'Archives found: {", ".join(files)}')
else:
print('Archives not found ...')
if not files:
print('Archives not found ...')
subprocess.check_call(['pybuild'])
files = list(glob.glob(f'dist/*{ver}*'))
files = [fn for fn in glob.glob(f'dist/*{ver}*') if not fn.endswith('.asc')]
for fn in files:
cmd = ['gpg', '-abs', fn]
subprocess.check_call(cmd)
sfn = f'{fn}.asc'
if os.path.exists(sfn):
os.remove(sfn)
cmd = ['gpg2', '-abs', fn]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.communicate()
assert p.returncode == 0
if options.upload:
cmd = ['twine', 'upload', '-r', 'python-gnupg']
cmd.extend(files)
Expand Down

0 comments on commit 77941ef

Please sign in to comment.