diff --git a/.gitignore b/.gitignore index 55472e67..a06fecec 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,4 @@ venv *.pyc .mypy_cache .hypothesis -publish.sh pip-wheel-metadata diff --git a/publish.py b/publish.py new file mode 100644 index 00000000..801145f9 --- /dev/null +++ b/publish.py @@ -0,0 +1,19 @@ +import argparse +import re +import subprocess + +version_pattern = '\d\.\d\.\d' +parser = argparse.ArgumentParser() +parser.add_argument('version', help='a SEMVER string X.Y.Z') +args = parser.parse_args() +if not re.match(version_pattern, args.version): + print('argument must be SEMVER string in format X.Y.Z') +else: + with open('setup.py') as fp: + old_setupfile = fp.read() + new_setupfile = re.sub(f"version='{version_pattern}'", + f"version='{args.version}'", old_setupfile) + with open('setup.py', 'w') as fp: + print(new_setupfile, file=fp) + + subprocess.run(['./publish.sh', 'v' + args.version]) diff --git a/publish.sh b/publish.sh new file mode 100755 index 00000000..edd0c61f --- /dev/null +++ b/publish.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +. venv/bin/activate +git add . +git commit -m "Release $1" +git push +git tag "$1" +git push --tags +hub release create "$1" +portray on_github_pages +python setup.py sdist bdist_wheel +twine upload dist/* diff --git a/setup.py b/setup.py index ac23fcd4..ab294ddf 100644 --- a/setup.py +++ b/setup.py @@ -33,5 +33,9 @@ 'portray' ] }, - include_package_data=True + include_package_data=True, + scripts=['publish.py'] ) + + +