diff --git a/.copier-answers.yml b/.copier-answers.yml index 6f6a6af..0059d8e 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -4,11 +4,11 @@ _src_path: https://github.com/trobz/trobz-python-template.git author_email: hailn@trobz.com author_username: hailangvn enable_github_action: true -package_name: deploy +package_name: trobz_deploy project_description: CLI tool for deploying and managing applications on remote servers over SSH. -project_name: deploy +project_name: trobz-deploy project_type: cli -publish_to_pypi: false -repository_name: deploy +publish_to_pypi: true +repository_name: deploy.py repository_namespace: trobz diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e77a16f..8a91ae8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,3 +38,35 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} git_committer_name: "github-actions" git_committer_email: "actions@users.noreply.github.com" + + + publish: + needs: release + if: needs.release.outputs.released == 'true' + runs-on: ubuntu-latest + + permissions: + contents: write + + id-token: write + + environment: + name: pypi + url: https://pypi.org/p/trobz-deploy + + steps: + - name: Check out at new tag + uses: actions/checkout@v6 + with: + ref: ${{ needs.release.outputs.tag }} + + - name: Set up the environment + uses: ./.github/actions/setup-python-env + + - name: Build Package + run: make build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@v1.13.0 + with: + packages-dir: dist diff --git a/pyproject.toml b/pyproject.toml index c19fe0e..ca72257 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "deploy" +name = "trobz-deploy" version = "0.8.0" description = "CLI tool for deploying and managing applications on remote servers over SSH." authors = [{name = "hailangvn", email = "hailn@trobz.com"}] @@ -17,7 +17,7 @@ dependencies = [ [project.urls] Repository = "https://github.com/trobz/deploy.py" [project.scripts] -deploy = "deploy.cli:cli" +deploy = "trobz_deploy.cli:cli" [dependency-groups] dev = [ @@ -37,7 +37,7 @@ requires = ["uv_build>=0.7.19,<0.8.0"] build-backend = "uv_build" [tool.uv.build-backend] -module-name = "deploy" +module-name = "trobz_deploy" module-root = "" @@ -48,7 +48,7 @@ build = ["uv ~= 0.7.12"] version_toml = ["pyproject.toml:project.version"] build_command = """ python -m pip install -e '.[build]' - uv lock --upgrade-package deploy + uv lock --upgrade-package trobz-deploy git add uv.lock uv build """ diff --git a/tests/test_config.py b/tests/test_config.py index 029949d..d75068a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,6 +1,6 @@ import pytest -from deploy.utils.config import parse_instance_name +from trobz_deploy.utils.config import parse_instance_name # --------------------------------------------------------------------------- # Valid names from the SPEC examples diff --git a/tests/test_update_watch.py b/tests/test_update_watch.py index 8bd6c26..90d2e3f 100644 --- a/tests/test_update_watch.py +++ b/tests/test_update_watch.py @@ -5,7 +5,7 @@ import pytest from click.testing import CliRunner -from deploy.command.update import update +from trobz_deploy.command.update import update @pytest.fixture @@ -21,8 +21,8 @@ def _executor_mock(): def _invoke(runner, extra_args: list[str], side_effect=None): with ( - patch("deploy.command.update.Executor") as MockExecutor, - patch("deploy.command.update.load_config", return_value={}), + patch("trobz_deploy.command.update.Executor") as MockExecutor, + patch("trobz_deploy.command.update.load_config", return_value={}), ): mock_exec = _executor_mock() if side_effect: diff --git a/deploy/__init__.py b/trobz_deploy/__init__.py similarity index 100% rename from deploy/__init__.py rename to trobz_deploy/__init__.py diff --git a/deploy/cli.py b/trobz_deploy/cli.py similarity index 82% rename from deploy/cli.py rename to trobz_deploy/cli.py index c34ef56..84a39a5 100644 --- a/deploy/cli.py +++ b/trobz_deploy/cli.py @@ -2,9 +2,9 @@ import click -from deploy.command.configure import configure -from deploy.command.status import status -from deploy.command.update import update +from trobz_deploy.command.configure import configure +from trobz_deploy.command.status import status +from trobz_deploy.command.update import update @click.group() diff --git a/deploy/command/__init__.py b/trobz_deploy/command/__init__.py similarity index 100% rename from deploy/command/__init__.py rename to trobz_deploy/command/__init__.py diff --git a/deploy/command/configure.py b/trobz_deploy/command/configure.py similarity index 96% rename from deploy/command/configure.py rename to trobz_deploy/command/configure.py index b5334bb..616f4d5 100644 --- a/deploy/command/configure.py +++ b/trobz_deploy/command/configure.py @@ -4,10 +4,10 @@ import click -from deploy.utils.config import load_config, resolve_options -from deploy.utils.executor import Executor, ExecutorError -from deploy.utils.render import render_unit -from deploy.utils.venv import setup_odoo_venv, setup_package_venv, setup_python_venv +from trobz_deploy.utils.config import load_config, resolve_options +from trobz_deploy.utils.executor import Executor, ExecutorError +from trobz_deploy.utils.render import render_unit +from trobz_deploy.utils.venv import setup_odoo_venv, setup_package_venv, setup_python_venv def _is_git_repo(executor: Executor, path: str) -> bool: diff --git a/deploy/command/status.py b/trobz_deploy/command/status.py similarity index 95% rename from deploy/command/status.py rename to trobz_deploy/command/status.py index f34c6e8..3d8ff55 100644 --- a/deploy/command/status.py +++ b/trobz_deploy/command/status.py @@ -2,8 +2,8 @@ import click -from deploy.utils.config import load_config -from deploy.utils.executor import Executor, ExecutorError +from trobz_deploy.utils.config import load_config +from trobz_deploy.utils.executor import Executor, ExecutorError @click.command() diff --git a/deploy/command/update.py b/trobz_deploy/command/update.py similarity index 96% rename from deploy/command/update.py rename to trobz_deploy/command/update.py index e6e6ee8..a02e3d5 100644 --- a/deploy/command/update.py +++ b/trobz_deploy/command/update.py @@ -2,10 +2,10 @@ import click -from deploy.utils.addons import get_addons_path -from deploy.utils.config import load_config, resolve_options -from deploy.utils.executor import Executor, ExecutorError -from deploy.utils.venv import setup_python_deps, upgrade_package +from trobz_deploy.utils.addons import get_addons_path +from trobz_deploy.utils.config import load_config, resolve_options +from trobz_deploy.utils.executor import Executor, ExecutorError +from trobz_deploy.utils.venv import setup_python_deps, upgrade_package @click.command() diff --git a/deploy/templates/__init__.py b/trobz_deploy/templates/__init__.py similarity index 100% rename from deploy/templates/__init__.py rename to trobz_deploy/templates/__init__.py diff --git a/deploy/templates/odoo.service.j2 b/trobz_deploy/templates/odoo.service.j2 similarity index 100% rename from deploy/templates/odoo.service.j2 rename to trobz_deploy/templates/odoo.service.j2 diff --git a/deploy/templates/python.service.j2 b/trobz_deploy/templates/python.service.j2 similarity index 100% rename from deploy/templates/python.service.j2 rename to trobz_deploy/templates/python.service.j2 diff --git a/deploy/templates/service.service.j2 b/trobz_deploy/templates/service.service.j2 similarity index 100% rename from deploy/templates/service.service.j2 rename to trobz_deploy/templates/service.service.j2 diff --git a/deploy/utils/__init__.py b/trobz_deploy/utils/__init__.py similarity index 100% rename from deploy/utils/__init__.py rename to trobz_deploy/utils/__init__.py diff --git a/deploy/utils/addons.py b/trobz_deploy/utils/addons.py similarity index 83% rename from deploy/utils/addons.py rename to trobz_deploy/utils/addons.py index ca8cb02..20f251f 100644 --- a/deploy/utils/addons.py +++ b/trobz_deploy/utils/addons.py @@ -1,6 +1,6 @@ from __future__ import annotations -from deploy.utils.executor import Executor +from trobz_deploy.utils.executor import Executor def get_addons_path(executor: Executor, instance_path: str) -> str: diff --git a/deploy/utils/config.py b/trobz_deploy/utils/config.py similarity index 100% rename from deploy/utils/config.py rename to trobz_deploy/utils/config.py diff --git a/deploy/utils/executor.py b/trobz_deploy/utils/executor.py similarity index 100% rename from deploy/utils/executor.py rename to trobz_deploy/utils/executor.py diff --git a/deploy/utils/render.py b/trobz_deploy/utils/render.py similarity index 94% rename from deploy/utils/render.py rename to trobz_deploy/utils/render.py index b6ac645..31d03f9 100644 --- a/deploy/utils/render.py +++ b/trobz_deploy/utils/render.py @@ -16,7 +16,7 @@ def render_unit(template_name: str, **variables: Any) -> str: Returns: Rendered unit file content as a string. """ - pkg = files("deploy.templates") + pkg = files("trobz_deploy.templates") source = (pkg / f"{template_name}.service.j2").read_text(encoding="utf-8") env = Environment(autoescape=select_autoescape(["html", "htm", "xml"])) template = env.from_string(source) diff --git a/deploy/utils/venv.py b/trobz_deploy/utils/venv.py similarity index 96% rename from deploy/utils/venv.py rename to trobz_deploy/utils/venv.py index ed24725..5ce288e 100644 --- a/deploy/utils/venv.py +++ b/trobz_deploy/utils/venv.py @@ -1,6 +1,6 @@ from __future__ import annotations -from deploy.utils.executor import Executor +from trobz_deploy.utils.executor import Executor def setup_odoo_venv(executor: Executor, instance_path: str) -> None: diff --git a/uv.lock b/uv.lock index 7358ee3..977d228 100644 --- a/uv.lock +++ b/uv.lock @@ -151,48 +151,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, ] -[[package]] -name = "deploy" -version = "0.8.0" -source = { editable = "." } -dependencies = [ - { name = "click" }, - { name = "jinja2" }, - { name = "pyyaml" }, -] - -[package.optional-dependencies] -build = [ - { name = "uv" }, -] - -[package.dev-dependencies] -dev = [ - { name = "pre-commit" }, - { name = "pytest" }, - { name = "python-semantic-release" }, - { name = "ruff" }, - { name = "ty" }, -] - -[package.metadata] -requires-dist = [ - { name = "click", specifier = ">=8.0" }, - { name = "jinja2", specifier = ">=3.0" }, - { name = "pyyaml", specifier = ">=6.0" }, - { name = "uv", marker = "extra == 'build'", specifier = "~=0.7.12" }, -] -provides-extras = ["build"] - -[package.metadata.requires-dev] -dev = [ - { name = "pre-commit", specifier = ">=2.20.0" }, - { name = "pytest", specifier = ">=7.2.0" }, - { name = "python-semantic-release", specifier = ">=10.5.3" }, - { name = "ruff", specifier = ">=0.11.5" }, - { name = "ty", specifier = ">=0.0.1a16" }, -] - [[package]] name = "deprecated" version = "1.3.1" @@ -894,6 +852,48 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/bd/75/8539d011f6be8e29f339c42e633aae3cb73bffa95dd0f9adec09b9c58e85/tomlkit-0.13.3-py3-none-any.whl", hash = "sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0", size = 38901, upload-time = "2025-06-05T07:13:43.546Z" }, ] +[[package]] +name = "trobz-deploy" +version = "0.8.0" +source = { editable = "." } +dependencies = [ + { name = "click" }, + { name = "jinja2" }, + { name = "pyyaml" }, +] + +[package.optional-dependencies] +build = [ + { name = "uv" }, +] + +[package.dev-dependencies] +dev = [ + { name = "pre-commit" }, + { name = "pytest" }, + { name = "python-semantic-release" }, + { name = "ruff" }, + { name = "ty" }, +] + +[package.metadata] +requires-dist = [ + { name = "click", specifier = ">=8.0" }, + { name = "jinja2", specifier = ">=3.0" }, + { name = "pyyaml", specifier = ">=6.0" }, + { name = "uv", marker = "extra == 'build'", specifier = "~=0.7.12" }, +] +provides-extras = ["build"] + +[package.metadata.requires-dev] +dev = [ + { name = "pre-commit", specifier = ">=2.20.0" }, + { name = "pytest", specifier = ">=7.2.0" }, + { name = "python-semantic-release", specifier = ">=10.5.3" }, + { name = "ruff", specifier = ">=0.11.5" }, + { name = "ty", specifier = ">=0.0.1a16" }, +] + [[package]] name = "ty" version = "0.0.21"