diff --git a/duties.py b/duties.py index 238d735..26e49a1 100644 --- a/duties.py +++ b/duties.py @@ -139,3 +139,37 @@ def export(ctx): with requirements_dev.open("w", encoding="utf-8") as req: req.write(requirements_dev_content) + + +@duty +def publish(ctx, password:str): + """ + Publish the package to pypi.org. + + Args: + password (str): pypi.org password. + + Example: + `duty publish password=$my_password` + """ + dist_dir = pathlib.Path(".") / "dist" + rm_result = rm_tree(dist_dir) + print(rm_result) + + publish_result = ctx.run(["poetry", "publish", "-u", "dtomlinson", "-p", password, "--build"]) + print(publish_result) + + +def rm_tree(directory: pathlib.Path): + """ + Recursively delete a directory and all its contents. + + Args: + directory (pathlib.Path): The directory to delete. + """ + for child in directory.glob('*'): + if child.is_file(): + child.unlink() + else: + rm_tree(child) + directory.rmdir() diff --git a/panaetius/_version.py b/panaetius/_version.py index 8a6fc0a..42dd00f 100644 --- a/panaetius/_version.py +++ b/panaetius/_version.py @@ -1,3 +1,3 @@ """Module containing the version of panaetius.""" -__version__ = "2.3.1" +__version__ = "2.3.2" diff --git a/pyproject.toml b/pyproject.toml index cbb933f..926a01f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "panaetius" -version = "2.3.1" +version = "2.3.2" description = "Python module to gracefully handle a .config file/environment variables for scripts, with built in masking for sensitive options. Provides a Splunk friendly formatted logger instance." license = "MIT" authors = ["dtomlinson "]