From 6f018f7713064156eef235cadc03cc891db682d0 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Sat, 22 Jul 2023 16:24:38 +0100 Subject: [PATCH] Add release script. --- gnupg.py | 2 +- release | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100755 release diff --git a/gnupg.py b/gnupg.py index 449def9..b900baa 100644 --- a/gnupg.py +++ b/gnupg.py @@ -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$' diff --git a/release b/release new file mode 100755 index 0000000..cc29eb6 --- /dev/null +++ b/release @@ -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) diff --git a/setup.cfg b/setup.cfg index 1391150..88a0efc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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.