@@ -352,6 +352,10 @@ def build(ctx):
352352 """
353353
354354 message_box ('Building...' )
355+ if 'modified: pyproject.toml' in ctx .run ('git status' ).stdout :
356+ raise RuntimeError (
357+ 'Please commit your changes to the "pyproject.toml" file!' )
358+
355359 pyproject_content = toml .load ('pyproject.toml' )
356360 pyproject_content ['tool' ]['poetry' ]['name' ] = PYPI_PACKAGE_NAME
357361 pyproject_content ['tool' ]['poetry' ]['packages' ] = [{
@@ -361,8 +365,25 @@ def build(ctx):
361365 with open ('pyproject.toml' , 'w' ) as pyproject_file :
362366 toml .dump (pyproject_content , pyproject_file )
363367
368+ if 'modified: README.rst' in ctx .run ('git status' ).stdout :
369+ raise RuntimeError (
370+ 'Please commit your changes to the "README.rst" file!' )
371+
372+ with open ('README.rst' , 'r' ) as readme_file :
373+ readme_content = readme_file .read ()
374+
375+ with open ('README.rst' , 'w' ) as readme_file :
376+ readme_file .write (
377+ re .sub (
378+ ('(\\ .\\ . begin-trim-long-description.*?'
379+ '\\ .\\ . end-trim-long-description)' ),
380+ '' ,
381+ readme_content ,
382+ flags = re .DOTALL ))
383+
364384 ctx .run ('poetry build' )
365385 ctx .run ('git checkout -- pyproject.toml' )
386+ ctx .run ('git checkout -- README.rst' )
366387
367388 with ctx .cd ('dist' ):
368389 ctx .run ('tar -xvf {0}-{1}.tar.gz' .format (PYPI_PACKAGE_NAME ,
@@ -405,6 +426,8 @@ def sub_callable(match):
405426 with open ('setup.py' , 'w' ) as setup_file :
406427 setup_file .write (source )
407428
429+ ctx .run ('twine check dist/*' )
430+
408431
409432@task
410433def virtualise (ctx , tests = True ):
@@ -488,7 +511,7 @@ def tag(ctx):
488511 ctx .run ('git flow release finish v{0}' .format (version ))
489512
490513
491- @task (clean , build )
514+ @task (build )
492515def release (ctx ):
493516 """
494517 Releases the project to *Pypi* with *Twine*.
0 commit comments