diff --git a/Makefile b/Makefile index 7027e04..4427375 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ pytest: install ## Run pytest poetry run python3 ./run_pytest.py publish: ## Release new version to PyPi - poetry run publish + poetry run python3 ./publish.py local-test: install ## Run local_test.py to run the project locally poetry run python3 ./local_test.py diff --git a/publish.py b/publish.py new file mode 100644 index 0000000..932d123 --- /dev/null +++ b/publish.py @@ -0,0 +1,31 @@ +from pathlib import Path + +from poetry_publish.publish import poetry_publish +from poetry_publish.utils.subprocess_utils import verbose_check_call + +import django_ynh +from django_ynh.path_utils import assert_is_file + + +PACKAGE_ROOT = Path(django_ynh.__file__).parent.parent.parent + + +def publish(): + """ + Publish to PyPi + Call this via: + $ make publish + """ + assert_is_file(PACKAGE_ROOT / 'README.md') + + verbose_check_call('make', 'pytest') # don't publish if tests fail + verbose_check_call('make', 'fix-code-style') # don't publish if code style wrong + + poetry_publish( + package_root=PACKAGE_ROOT, + version=django_ynh.__version__, + creole_readme=True, # don't publish if README.rst is not up-to-date + ) + +if __name__ == '__main__': + publish() diff --git a/pyproject.toml b/pyproject.toml index 86594b1..834d5e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] create_superuser = "django_ynh.create_superuser:main" -publish = "django_ynh_tests.test_project.publish:publish" [tool.isort] # https://pycqa.github.io/isort/docs/configuration/config_files/#pyprojecttoml-preferred-format