build: make clean dist folder for each release

this obviates the need to parse app version.  but also i found a clue
online that said `twine upload dist/*` was the usual way to run things
This commit is contained in:
Lance Edgar 2024-06-10 19:47:29 -05:00
parent 7db3221ec0
commit 1788ad0528

View file

@ -25,36 +25,22 @@ Tasks for tailbone-wave
""" """
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): def release(c):
""" """
Release a new version of tailbone-wave Release a new version of tailbone-wave
""" """
# rebuild local tar.gz file for distribution # rebuild package
if os.path.exists('dist'):
shutil.rmtree('dist')
if os.path.exists('tailbone_wave.egg-info'): if os.path.exists('tailbone_wave.egg-info'):
shutil.rmtree('tailbone_wave.egg-info') shutil.rmtree('tailbone_wave.egg-info')
c.run('python -m build --sdist') c.run('python -m build --sdist')
# upload to public PyPI # upload to public PyPI
filename = 'tailbone-wave-{}.tar.gz'.format(__version__) c.run('twine upload dist/*')
c.run('twine upload dist/{}'.format(filename))