Skip to content

Commit

Permalink
Add release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Jul 22, 2023
1 parent da44376 commit 6f018f7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import sys
import threading

__version__ = '0.5.1'
__version__ = '0.5.2.dev0'
__author__ = 'Vinay Sajip'
__date__ = '$22-Jul-2023 16:36:40$'

Expand Down
70 changes: 70 additions & 0 deletions release
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2023 Red Dove Consultants Limited
#
import argparse
import glob
import logging
import os
import re
import subprocess
import sys

DEBUGGING = 'PY_DEBUG' in os.environ

logger = logging.getLogger(__name__)


def main():
fn = os.path.basename(__file__)
fn = os.path.splitext(fn)[0]
lfn = os.path.expanduser('~/logs/%s.log' % fn)
if os.path.isdir(os.path.dirname(lfn)):
logging.basicConfig(level=logging.DEBUG, filename=lfn, filemode='w',
format='%(message)s')
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')
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:
print(f'Signatures found: {", ".join(sigs)}')
else:
print('Signatures not found ...')
files = list(glob.glob(f'dist/*{ver}*'))
if files:
print(f'Archives found: {", ".join(files)}')
else:
print('Archives not found ...')
subprocess.check_call(['pybuild'])
files = list(glob.glob(f'dist/*{ver}*'))
for fn in files:
cmd = ['gpg', '-abs', fn]
subprocess.check_call(cmd)
if options.upload:
cmd = ['twine', 'upload', '-r', 'python-gnupg']
cmd.extend(files)
subprocess.check_call(cmd)


if __name__ == '__main__':
try:
rc = main()
except KeyboardInterrupt:
rc = 2
except Exception as e:
if DEBUGGING:
s = ' %s:' % type(e).__name__
else:
s = ''
sys.stderr.write('Failed:%s %s\n' % (s, e))
if DEBUGGING: import traceback; traceback.print_exc()
rc = 1
sys.exit(rc)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ long_description =
As PyPI no longer shows signatures, you should be able to download release archives
and signatures from
https://bitbucket.org/vinay.sajip/python-gnupg/downloads/
https://github.com/vsajip/python-gnupg/releases/
The archives should be the same as those uploaded to PyPI.
Expand Down

0 comments on commit 6f018f7

Please sign in to comment.