pyforge-deploy 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyforge_deploy-0.2.1/src/pyforge_deploy.egg-info → pyforge_deploy-0.2.2}/PKG-INFO +1 -2
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/README.md +0 -1
- pyforge_deploy-0.2.2/src/pyforge_deploy/__about__.py +1 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/builders/docker.py +32 -18
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/cli.py +39 -0
- pyforge_deploy-0.2.2/src/pyforge_deploy/templates/workflows.py +30 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2/src/pyforge_deploy.egg-info}/PKG-INFO +1 -2
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy.egg-info/SOURCES.txt +1 -0
- pyforge_deploy-0.2.1/src/pyforge_deploy/__about__.py +0 -1
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/LICENSE +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/MANIFEST.in +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/pyproject.toml +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/requirements-dev.txt +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/setup.cfg +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/__init__.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/builders/__init__.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/builders/docker_engine.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/builders/pypi.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/builders/version_engine.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/colors.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/py.typed +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy/templates/Dockerfile.j2 +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy.egg-info/dependency_links.txt +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy.egg-info/entry_points.txt +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy.egg-info/requires.txt +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy.egg-info/top_level.txt +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/tests/test_cli.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/tests/test_colors.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/tests/test_docker.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/tests/test_docker_engine.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/tests/test_pypi.py +0 -0
- {pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/tests/test_version_engine.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyforge-deploy
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Lightweight automation tool designed to streamline the transition from development to distribution.
|
|
5
5
|
Author-email: Ertan Tunç Türk <ertantuncturk61@gmail.com>
|
|
6
6
|
Maintainer-email: Ertan Tunç Türk <ertantuncturk61@gmail.com>
|
|
@@ -46,7 +46,6 @@ Dynamic: license-file
|
|
|
46
46
|
> **Note:** This is a personal/educational project. It is not intended to compete with established
|
|
47
47
|
> tools
|
|
48
48
|
|
|
49
|
-
[](https://pypi.org/project/pyforge-deploy/)
|
|
50
49
|
[](LICENSE)
|
|
51
50
|
|
|
52
51
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
> **Note:** This is a personal/educational project. It is not intended to compete with established
|
|
4
4
|
> tools
|
|
5
5
|
|
|
6
|
-
[](https://pypi.org/project/pyforge-deploy/)
|
|
7
6
|
[](LICENSE)
|
|
8
7
|
|
|
9
8
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# nosec B404: subprocess usage is safe, no shell=True, command is a list
|
|
2
|
+
import os
|
|
2
3
|
import subprocess # nosec
|
|
3
4
|
import sys as _sys
|
|
4
5
|
from pathlib import Path
|
|
@@ -26,33 +27,46 @@ class DockerBuilder:
|
|
|
26
27
|
) -> None:
|
|
27
28
|
self.base_dir: Path = Path.cwd()
|
|
28
29
|
self.verbose: bool = verbose
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
30
|
+
|
|
31
|
+
if image_tag:
|
|
32
|
+
self.image_tag = image_tag
|
|
33
|
+
else:
|
|
34
|
+
try:
|
|
35
|
+
from .version_engine import get_dynamic_version, get_project_details
|
|
36
|
+
|
|
37
|
+
p_name, _ = get_project_details()
|
|
38
|
+
p_ver = get_dynamic_version()
|
|
39
|
+
|
|
40
|
+
user = os.environ.get("DOCKERHUB_USERNAME", "").lower()
|
|
41
|
+
|
|
42
|
+
if user:
|
|
43
|
+
self.image_tag = f"{user}/{p_name}:{p_ver}"
|
|
44
|
+
else:
|
|
45
|
+
self.image_tag = f"{p_name}:{p_ver}"
|
|
46
|
+
except Exception:
|
|
47
|
+
self.image_tag = self.base_dir.name.lower().replace(" ", "-")
|
|
48
|
+
|
|
49
|
+
self._validate_image_tag(self.image_tag)
|
|
50
|
+
|
|
39
51
|
self.entry_point: str | None = entry_point
|
|
40
|
-
|
|
52
|
+
self.dockerfile_path: Path = self.base_dir / "Dockerfile"
|
|
53
|
+
self.req_docker_path: Path = self.base_dir / "requirements-docker.txt"
|
|
54
|
+
|
|
55
|
+
def _validate_image_tag(self, tag: str) -> None:
|
|
56
|
+
"""Validates image_tag for Docker safety."""
|
|
41
57
|
valid_chars = "-./_:"
|
|
42
|
-
|
|
58
|
+
sanitized = tag
|
|
43
59
|
for char in valid_chars:
|
|
44
|
-
|
|
60
|
+
sanitized = sanitized.replace(char, "")
|
|
45
61
|
|
|
46
|
-
if
|
|
62
|
+
if not sanitized.isalnum():
|
|
47
63
|
raise ValueError(
|
|
48
64
|
color_text(
|
|
49
|
-
"Error: image_tag
|
|
65
|
+
f"Error: image_tag '{tag}' contains invalid characters. "
|
|
66
|
+
"Only alphanumeric and (- . / _ :) are allowed.",
|
|
50
67
|
"red",
|
|
51
68
|
)
|
|
52
69
|
)
|
|
53
|
-
self.image_tag: str = image_tag or self.base_dir.name.lower().replace(" ", "-")
|
|
54
|
-
self.dockerfile_path: Path = self.base_dir / "Dockerfile"
|
|
55
|
-
self.req_docker_path: Path = self.base_dir / "requirements-docker.txt"
|
|
56
70
|
|
|
57
71
|
def _generate_docker_requirements(self, final_list: list[str]) -> None:
|
|
58
72
|
"""Writes the detected dependencies to requirements-docker.txt."""
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
import argparse
|
|
4
4
|
import os
|
|
5
5
|
import sys
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
from pyforge_deploy.builders.docker import DockerBuilder
|
|
8
9
|
from pyforge_deploy.builders.docker_engine import detect_dependencies
|
|
9
10
|
from pyforge_deploy.builders.pypi import PyPIDistributor
|
|
10
11
|
from pyforge_deploy.builders.version_engine import get_dynamic_version
|
|
11
12
|
from pyforge_deploy.colors import color_text
|
|
13
|
+
from pyforge_deploy.templates.workflows import GITHUB_RELEASE_YAML
|
|
12
14
|
|
|
13
15
|
EXAMPLES = """
|
|
14
16
|
Examples:
|
|
@@ -43,6 +45,12 @@ def main() -> None:
|
|
|
43
45
|
dest="command", required=True, help="Available commands"
|
|
44
46
|
)
|
|
45
47
|
|
|
48
|
+
init_parser = subparsers.add_parser(
|
|
49
|
+
"init",
|
|
50
|
+
help="Initialize pyforge-deploy GitHub Action workflow in the current project.",
|
|
51
|
+
description="Creates a professional .github/workflows/pyforge-deploy.yml file.",
|
|
52
|
+
)
|
|
53
|
+
|
|
46
54
|
docker_parser = subparsers.add_parser("docker-build", help="Build a Docker image.")
|
|
47
55
|
docker_parser.add_argument("--entry-point", type=str, default=None)
|
|
48
56
|
docker_parser.add_argument("--image-tag", type=str, default=None)
|
|
@@ -50,6 +58,36 @@ def main() -> None:
|
|
|
50
58
|
"--verbose", action="store_true", help="Enable verbose logging."
|
|
51
59
|
)
|
|
52
60
|
|
|
61
|
+
def init_handler(args: argparse.Namespace) -> None:
|
|
62
|
+
workflow_dir = Path(".github/workflows")
|
|
63
|
+
workflow_dir.mkdir(parents=True, exist_ok=True)
|
|
64
|
+
|
|
65
|
+
target_path = workflow_dir / "pyforge-deploy.yml"
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
with open(target_path, "w", encoding="utf-8") as f:
|
|
69
|
+
f.write(GITHUB_RELEASE_YAML.strip())
|
|
70
|
+
|
|
71
|
+
print(color_text(f"Successfully created: {target_path}", "green"))
|
|
72
|
+
print(color_text("Next Steps:", "blue"))
|
|
73
|
+
print(
|
|
74
|
+
color_text(
|
|
75
|
+
"1. Go to your GitHub Repository Settings > Secrets.", "yellow"
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
print(
|
|
79
|
+
color_text(
|
|
80
|
+
"2. Add 'PYPI_TOKEN', 'DOCKERHUB_USERNAME', and 'DOCKERHUB_TOKEN'.",
|
|
81
|
+
"yellow",
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
print(
|
|
85
|
+
color_text("3. Push your changes and watch the magic happen!", "yellow")
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
except Exception as e:
|
|
89
|
+
print(color_text(f"Error: Could not create workflow file: {e}", "red"))
|
|
90
|
+
|
|
53
91
|
def docker_build_handler(args: argparse.Namespace) -> None:
|
|
54
92
|
builder = DockerBuilder(
|
|
55
93
|
entry_point=args.entry_point, image_tag=args.image_tag, verbose=args.verbose
|
|
@@ -63,6 +101,7 @@ def main() -> None:
|
|
|
63
101
|
sys.exit(1)
|
|
64
102
|
|
|
65
103
|
docker_parser.set_defaults(func=docker_build_handler)
|
|
104
|
+
init_parser.set_defaults(func=init_handler)
|
|
66
105
|
|
|
67
106
|
pypi_parser = subparsers.add_parser("deploy-pypi", help="Deploy to PyPI.")
|
|
68
107
|
pypi_parser.add_argument("--test", action="store_true")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
GITHUB_RELEASE_YAML = """name: PyForge Auto-Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
release:
|
|
12
|
+
name: Build and Publish
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout Code
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
|
|
20
|
+
- name: PyForge Deploy
|
|
21
|
+
uses: ertanturk/pyforge-deploy@main
|
|
22
|
+
with:
|
|
23
|
+
pypi_deploy: 'true'
|
|
24
|
+
docker_build: 'true'
|
|
25
|
+
bump: 'patch'
|
|
26
|
+
env:
|
|
27
|
+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
28
|
+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
29
|
+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
30
|
+
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyforge-deploy
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Lightweight automation tool designed to streamline the transition from development to distribution.
|
|
5
5
|
Author-email: Ertan Tunç Türk <ertantuncturk61@gmail.com>
|
|
6
6
|
Maintainer-email: Ertan Tunç Türk <ertantuncturk61@gmail.com>
|
|
@@ -46,7 +46,6 @@ Dynamic: license-file
|
|
|
46
46
|
> **Note:** This is a personal/educational project. It is not intended to compete with established
|
|
47
47
|
> tools
|
|
48
48
|
|
|
49
|
-
[](https://pypi.org/project/pyforge-deploy/)
|
|
50
49
|
[](LICENSE)
|
|
51
50
|
|
|
52
51
|
|
|
@@ -20,6 +20,7 @@ src/pyforge_deploy/builders/docker_engine.py
|
|
|
20
20
|
src/pyforge_deploy/builders/pypi.py
|
|
21
21
|
src/pyforge_deploy/builders/version_engine.py
|
|
22
22
|
src/pyforge_deploy/templates/Dockerfile.j2
|
|
23
|
+
src/pyforge_deploy/templates/workflows.py
|
|
23
24
|
tests/test_cli.py
|
|
24
25
|
tests/test_colors.py
|
|
25
26
|
tests/test_docker.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyforge_deploy-0.2.1 → pyforge_deploy-0.2.2}/src/pyforge_deploy.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|