build: simplify release task
per newer conventions
This commit is contained in:
parent
491df09f2f
commit
1aa597d2e5
20
tasks.py
20
tasks.py
|
@ -4,26 +4,11 @@ Tasks for WuttJamaican
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from invoke import task
|
from invoke import task
|
||||||
|
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
|
||||||
__version__ = None
|
|
||||||
pattern = re.compile(r'^version = "(\d+\.\d+\.\d+)"$')
|
|
||||||
with open(os.path.join(here, 'pyproject.toml'), 'rt') as f:
|
|
||||||
for line in f:
|
|
||||||
line = line.rstrip('\n')
|
|
||||||
match = pattern.match(line)
|
|
||||||
if match:
|
|
||||||
__version__ = match.group(1)
|
|
||||||
break
|
|
||||||
if not __version__:
|
|
||||||
raise RuntimeError("could not parse version!")
|
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def release(c, skip_tests=False):
|
def release(c, skip_tests=False):
|
||||||
"""
|
"""
|
||||||
|
@ -33,10 +18,11 @@ def release(c, skip_tests=False):
|
||||||
c.run('pytest')
|
c.run('pytest')
|
||||||
|
|
||||||
# rebuild local tar.gz file for distribution
|
# rebuild local tar.gz file for distribution
|
||||||
|
if os.path.exists('dist'):
|
||||||
|
shutil.rmtree('dist')
|
||||||
if os.path.exists('WuttJamaican.egg-info'):
|
if os.path.exists('WuttJamaican.egg-info'):
|
||||||
shutil.rmtree('WuttJamaican.egg-info')
|
shutil.rmtree('WuttJamaican.egg-info')
|
||||||
c.run('python -m build --sdist')
|
c.run('python -m build --sdist')
|
||||||
|
|
||||||
# upload to PyPI
|
# upload to PyPI
|
||||||
filename = f'wuttjamaican-{__version__}.tar.gz'
|
c.run('twine upload dist/*')
|
||||||
c.run(f'twine upload dist/{filename}')
|
|
||||||
|
|
Loading…
Reference in a new issue