-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters