diff --git a/pyproject.toml b/pyproject.toml index 6e69ee49..3f952fc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ sphinx-rtd-theme = "^3.0.2" gl-cname = "gardenlinux.features.cname_main:main" gl-features-parse = "gardenlinux.features.__main__:main" gl-flavors-parse = "gardenlinux.flavors.__main__:main" +gl-gh-release = "gardenlinux.github.release.__main__:main" gl-oci = "gardenlinux.oci.__main__:main" gl-s3 = "gardenlinux.s3.__main__:main" diff --git a/src/gardenlinux/constants.py b/src/gardenlinux/constants.py index 52f1cdec..b405f032 100644 --- a/src/gardenlinux/constants.py +++ b/src/gardenlinux/constants.py @@ -159,10 +159,10 @@ S3_DOWNLOADS_DIR = Path(os.path.dirname(__file__)) / ".." / "s3_downloads" +GL_DEB_REPO_BASE_URL = "https://packages.gardenlinux.io/gardenlinux" GLVD_BASE_URL = ( "https://glvd.ingress.glvd.gardnlinux.shoot.canary.k8s-hana.ondemand.com/v1" ) -GL_DEB_REPO_BASE_URL = "https://packages.gardenlinux.io/gardenlinux" GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME = "gardenlinux-github-releases" diff --git a/src/gardenlinux/github/__init__.py b/src/gardenlinux/github/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/gardenlinux/github/__main__.py b/src/gardenlinux/github/release/__main__.py similarity index 89% rename from src/gardenlinux/github/__main__.py rename to src/gardenlinux/github/release/__main__.py index de2a6f63..3bcf6e55 100644 --- a/src/gardenlinux/github/__main__.py +++ b/src/gardenlinux/github/release/__main__.py @@ -3,8 +3,12 @@ from gardenlinux.constants import GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME from gardenlinux.logger import LoggerSetup -from .release import create_github_release, upload_to_github_release_page, write_to_release_id_file -from .release_notes import create_github_release_notes +from . import ( + create_github_release, + upload_to_github_release_page, + write_to_release_id_file, +) +from ..release_notes import create_github_release_notes LOGGER = LoggerSetup.get_logger("gardenlinux.github", "INFO") @@ -18,7 +22,7 @@ def main(): create_parser.add_argument("--repo", default="gardenlinux") create_parser.add_argument("--tag", required=True) create_parser.add_argument("--commit", required=True) - create_parser.add_argument('--latest', action='store_true', default=False) + create_parser.add_argument("--latest", action="store_true", default=False) create_parser.add_argument("--dry-run", action="store_true", default=False) upload_parser = subparsers.add_parser("upload") diff --git a/tests/github/test_github_script.py b/tests/github/test_github_script.py index c94885a4..c6cc85ac 100644 --- a/tests/github/test_github_script.py +++ b/tests/github/test_github_script.py @@ -2,7 +2,7 @@ import pytest -import gardenlinux.github.__main__ as gh +import gardenlinux.github.release.__main__ as gh from gardenlinux.constants import GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME from ..constants import TEST_GARDENLINUX_COMMIT, TEST_GARDENLINUX_RELEASE @@ -44,7 +44,7 @@ def test_script_create_dry_run(monkeypatch, capfd): monkeypatch.setattr(sys, "argv", ["gh", "create", "--owner", "gardenlinux", "--repo", "gardenlinux", "--tag", TEST_GARDENLINUX_RELEASE, "--commit", TEST_GARDENLINUX_COMMIT, "--dry-run"]) - monkeypatch.setattr("gardenlinux.github.__main__.create_github_release_notes", + monkeypatch.setattr("gardenlinux.github.release.__main__.create_github_release_notes", lambda tag, commit, bucket: f"{tag} {commit} {bucket}") gh.main() @@ -57,9 +57,9 @@ def test_script_create_dry_run(monkeypatch, capfd): def test_script_create(monkeypatch, caplog): monkeypatch.setattr(sys, "argv", ["gh", "create", "--owner", "gardenlinux", "--repo", "gardenlinux", "--tag", TEST_GARDENLINUX_RELEASE, "--commit", TEST_GARDENLINUX_COMMIT]) - monkeypatch.setattr("gardenlinux.github.__main__.create_github_release_notes", + monkeypatch.setattr("gardenlinux.github.release.__main__.create_github_release_notes", lambda tag, commit, bucket: f"{tag} {commit} {bucket}") - monkeypatch.setattr("gardenlinux.github.__main__.create_github_release", + monkeypatch.setattr("gardenlinux.github.release.__main__.create_github_release", lambda a1, a2, a3, a4, a5, a6: TEST_GARDENLINUX_RELEASE) gh.main() @@ -71,7 +71,7 @@ def test_script_create(monkeypatch, caplog): def test_script_upload_dry_run(monkeypatch, capfd): monkeypatch.setattr(sys, "argv", ["gh", "upload", "--owner", "gardenlinux", "--repo", "gardenlinux", "--release_id", TEST_GARDENLINUX_RELEASE, "--file_path", "foo", "--dry-run"]) - monkeypatch.setattr("gardenlinux.github.__main__.upload_to_github_release_page", + monkeypatch.setattr("gardenlinux.github.release.__main__.upload_to_github_release_page", lambda a1, a2, a3, a4, dry_run: print(f"dry-run: {dry_run}")) gh.main() diff --git a/tests/github/test_upload_to_github_release_page.py b/tests/github/test_upload_to_github_release_page.py index 152b3d87..ee4159ab 100644 --- a/tests/github/test_upload_to_github_release_page.py +++ b/tests/github/test_upload_to_github_release_page.py @@ -4,7 +4,7 @@ import requests import requests_mock -import gardenlinux.github.__main__ as gh +import gardenlinux.github.release.__main__ as gh from gardenlinux.github.release import upload_to_github_release_page from ..constants import TEST_GARDENLINUX_RELEASE @@ -108,7 +108,7 @@ def test_script_parse_args_upload_command_required_args(monkeypatch, capfd): def test_script_upload_dry_run(monkeypatch, capfd): monkeypatch.setattr(sys, "argv", ["gh", "upload", "--owner", "gardenlinux", "--repo", "gardenlinux", "--release_id", TEST_GARDENLINUX_RELEASE, "--file_path", "foo", "--dry-run"]) - monkeypatch.setattr("gardenlinux.github.__main__.upload_to_github_release_page", + monkeypatch.setattr("gardenlinux.github.release.__main__.upload_to_github_release_page", lambda a1, a2, a3, a4, dry_run: print(f"dry-run: {dry_run}")) gh.main()