Skip to content

Commit

Permalink
chore: add publish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lidatong committed Nov 3, 2019
1 parent 0930eb1 commit 9f3749d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ venv
*.pyc
.mypy_cache
.hypothesis
publish.sh
pip-wheel-metadata
19 changes: 19 additions & 0 deletions publish.py
Original file line number Diff line number Diff line change
@@ -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])
12 changes: 12 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -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/*
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@
'portray'
]
},
include_package_data=True
include_package_data=True,
scripts=['publish.py']
)



0 comments on commit 9f3749d

Please sign in to comment.