unity-devkit 0.1.19__py3-none-any.whl → 0.1.21__py3-none-any.whl
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.
- unity_devkit/ci_build_unity.py +21 -12
- unity_devkit/compile_check_unity.py +22 -0
- unity_devkit/license.py +10 -25
- unity_devkit/license_restore.py +50 -4
- unity_devkit/matrix.py +45 -21
- unity_devkit/upm_cache.py +39 -0
- {unity_devkit-0.1.19.dist-info → unity_devkit-0.1.21.dist-info}/METADATA +1 -1
- unity_devkit-0.1.21.dist-info/RECORD +18 -0
- {unity_devkit-0.1.19.dist-info → unity_devkit-0.1.21.dist-info}/entry_points.txt +2 -3
- unity_devkit/dispatch_workflow_generator.py +0 -258
- unity_devkit-0.1.19.dist-info/RECORD +0 -18
- {unity_devkit-0.1.19.dist-info → unity_devkit-0.1.21.dist-info}/WHEEL +0 -0
unity_devkit/ci_build_unity.py
CHANGED
|
@@ -10,10 +10,11 @@ from pydantic_settings import BaseSettings
|
|
|
10
10
|
|
|
11
11
|
from ci_devkit.cache import restore, save
|
|
12
12
|
from ci_devkit.ci_step import ci_step
|
|
13
|
-
from .license_restore import restore_license
|
|
14
13
|
from ci_devkit.setup import configure_git, install_dotnet
|
|
15
14
|
from ci_devkit.setup_oras import install_oras
|
|
15
|
+
from .license_restore import restore_or_activate_license
|
|
16
16
|
from .player_build import build_player, parse_environment_fields, resolve_unity_project
|
|
17
|
+
from .upm_cache import restore_upm_cache, save_upm_cache
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class Settings(BaseSettings):
|
|
@@ -26,7 +27,6 @@ app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
|
26
27
|
@app.command()
|
|
27
28
|
def ci_build_unity(
|
|
28
29
|
project: Annotated[str, typer.Option(help="Project name")],
|
|
29
|
-
project_path: Annotated[Path, typer.Option(help="Path to Unity project")],
|
|
30
30
|
platform: Annotated[str, typer.Option(help="Target platform")],
|
|
31
31
|
cache_key: Annotated[str, typer.Option(help="Cache key prefix")],
|
|
32
32
|
registry: Annotated[str, typer.Option(help="OCI registry path for the library cache")],
|
|
@@ -51,7 +51,9 @@ def ci_build_unity(
|
|
|
51
51
|
configure_git(settings.github_workspace)
|
|
52
52
|
install_dotnet("8.0")
|
|
53
53
|
install_oras()
|
|
54
|
-
|
|
54
|
+
restore_or_activate_license()
|
|
55
|
+
project_path = resolve_unity_project(project).path
|
|
56
|
+
restore_upm_cache(project_path)
|
|
55
57
|
|
|
56
58
|
branch_slug = branch.replace("/", "-")
|
|
57
59
|
tag = f"{cache_key}-{platform}-{branch_slug}"
|
|
@@ -61,13 +63,6 @@ def ci_build_unity(
|
|
|
61
63
|
with ci_step("Restore library cache"):
|
|
62
64
|
restore(registry, "unity-library", tag, Path("."), fallback_tags=fallback_tags)
|
|
63
65
|
|
|
64
|
-
with ci_step("Prepare build"):
|
|
65
|
-
unity_project_path = resolve_unity_project(project).path
|
|
66
|
-
if unity_project_path.resolve() != project_path.resolve():
|
|
67
|
-
raise SystemExit(
|
|
68
|
-
f"--project-path {project_path} does not match discovered project '{project}' at {unity_project_path}"
|
|
69
|
-
)
|
|
70
|
-
|
|
71
66
|
with ci_step(f"Build {project} [{platform}]"):
|
|
72
67
|
build_player(
|
|
73
68
|
project,
|
|
@@ -85,7 +80,11 @@ def ci_build_unity(
|
|
|
85
80
|
if package_cache.exists():
|
|
86
81
|
shutil.rmtree(package_cache)
|
|
87
82
|
|
|
88
|
-
|
|
83
|
+
relative_project_path = project_path.relative_to(Path.cwd())
|
|
84
|
+
save(registry, "unity-library", tag, Path("."), [f"{relative_project_path}/Library/"])
|
|
85
|
+
|
|
86
|
+
with ci_step("Save UPM cache"):
|
|
87
|
+
save_upm_cache(project_path)
|
|
89
88
|
|
|
90
89
|
with ci_step("Collect build artifacts"):
|
|
91
90
|
build_directory = project_path / "Build"
|
|
@@ -98,6 +97,10 @@ def ci_build_unity(
|
|
|
98
97
|
for file in build_directory.rglob("*"):
|
|
99
98
|
if file.suffix in {".apk", ".exe"}:
|
|
100
99
|
shutil.copy2(file, artifact_directory / file.name)
|
|
100
|
+
for report in build_directory.rglob("BuildReport.json"):
|
|
101
|
+
destination = artifact_directory / report.relative_to(build_directory)
|
|
102
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
103
|
+
shutil.copy2(report, destination)
|
|
101
104
|
|
|
102
105
|
with ci_step("Push build artifacts"):
|
|
103
106
|
artifact_directory = Path("/tmp/unity-builds")
|
|
@@ -117,7 +120,13 @@ def ci_build_unity(
|
|
|
117
120
|
finally:
|
|
118
121
|
tar_path.unlink(missing_ok=True)
|
|
119
122
|
else:
|
|
120
|
-
joined = " ".join(
|
|
123
|
+
joined = " ".join(
|
|
124
|
+
sorted(
|
|
125
|
+
str(path.relative_to(artifact_directory))
|
|
126
|
+
for path in artifact_directory.rglob("*")
|
|
127
|
+
if path.is_file()
|
|
128
|
+
)
|
|
129
|
+
)
|
|
121
130
|
for build_tag in tags:
|
|
122
131
|
bash(f"oras push {reference_base}:{build_tag} {joined}", cwd=artifact_directory)
|
|
123
132
|
print(f"Pushed build artifacts: {reference_base} ({', '.join(tags)})")
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from typing import Annotated
|
|
2
4
|
|
|
3
5
|
import typer
|
|
6
|
+
from pydantic_settings import BaseSettings
|
|
4
7
|
|
|
8
|
+
from ci_devkit.ci_step import ci_step
|
|
9
|
+
from ci_devkit.setup import configure_git
|
|
10
|
+
from ci_devkit.setup_oras import install_oras
|
|
11
|
+
from .license_restore import restore_or_activate_license
|
|
5
12
|
from .player_build import prepare_unity_project, resolve_unity_project, run_unity_batchmode
|
|
13
|
+
from .upm_cache import restore_upm_cache, save_upm_cache
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Settings(BaseSettings):
|
|
17
|
+
github_workspace: str
|
|
18
|
+
|
|
6
19
|
|
|
7
20
|
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
8
21
|
|
|
@@ -21,7 +34,15 @@ def compile_check_unity(
|
|
|
21
34
|
typer.Option(help="Startup build target (e.g. Android) for sessions that must open on a non-default platform"),
|
|
22
35
|
] = None,
|
|
23
36
|
) -> None:
|
|
37
|
+
settings = Settings.model_validate({})
|
|
24
38
|
project_path = resolve_unity_project(project).path
|
|
39
|
+
|
|
40
|
+
with ci_step("Setup"):
|
|
41
|
+
configure_git(settings.github_workspace)
|
|
42
|
+
install_oras()
|
|
43
|
+
restore_or_activate_license()
|
|
44
|
+
restore_upm_cache(project_path)
|
|
45
|
+
|
|
25
46
|
extra_flags = ""
|
|
26
47
|
if build_target:
|
|
27
48
|
extra_flags += f" -buildTarget {build_target}"
|
|
@@ -30,4 +51,5 @@ def compile_check_unity(
|
|
|
30
51
|
print(f"Compile-checking {project}...")
|
|
31
52
|
prepare_unity_project(project_path)
|
|
32
53
|
run_unity_batchmode(project_path, extra_flags, extra_failure_signatures=COMPILE_ERROR_SIGNATURES)
|
|
54
|
+
save_upm_cache(project_path)
|
|
33
55
|
print(" Compiles clean")
|
unity_devkit/license.py
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from typing import Annotated
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
|
-
from bashrun.bash import bash
|
|
7
6
|
from pydantic_settings import BaseSettings
|
|
8
7
|
|
|
9
|
-
from ci_devkit.cache import restore, save
|
|
10
|
-
from .license_restore import license_cache_tag
|
|
11
8
|
from ci_devkit.setup import configure_git
|
|
12
9
|
from ci_devkit.setup_oras import install_oras
|
|
10
|
+
from .license_restore import activate_license, restore_or_activate_license
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
class Settings(BaseSettings):
|
|
16
|
-
cache_registry: str
|
|
17
14
|
github_workspace: str
|
|
18
|
-
unity_email: str
|
|
19
|
-
unity_password: str
|
|
20
|
-
unity_serial: str
|
|
21
15
|
|
|
22
16
|
|
|
23
17
|
settings = Settings.model_validate({})
|
|
@@ -25,23 +19,14 @@ activate_app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=F
|
|
|
25
19
|
|
|
26
20
|
|
|
27
21
|
@activate_app.command()
|
|
28
|
-
def activate_main(
|
|
22
|
+
def activate_main(
|
|
23
|
+
oras_push: Annotated[
|
|
24
|
+
bool, typer.Option(help="Restore from the ORAS cache on miss and push the activated ULF back")
|
|
25
|
+
] = False,
|
|
26
|
+
) -> None:
|
|
29
27
|
configure_git(settings.github_workspace)
|
|
30
28
|
install_oras()
|
|
31
|
-
|
|
32
|
-
license_directory = Path.home() / ".local" / "share" / "unity3d" / "Unity"
|
|
33
|
-
license_directory.mkdir(parents=True, exist_ok=True)
|
|
34
|
-
|
|
35
|
-
tag = license_cache_tag()
|
|
36
|
-
cache_hit = False
|
|
37
29
|
if oras_push:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
bash(
|
|
42
|
-
f'unity-editor -batchmode -nographics -quit -serial "{settings.unity_serial}"'
|
|
43
|
-
f' -username "{settings.unity_email}" -password "{settings.unity_password}" -logFile /dev/stdout'
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
if oras_push and not cache_hit:
|
|
47
|
-
save(settings.cache_registry, "unity-license", tag, license_directory, ["Unity_lic.ulf"])
|
|
30
|
+
restore_or_activate_license()
|
|
31
|
+
else:
|
|
32
|
+
activate_license()
|
unity_devkit/license_restore.py
CHANGED
|
@@ -1,32 +1,78 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from datetime import UTC, datetime
|
|
4
3
|
import os
|
|
4
|
+
import random
|
|
5
|
+
import time
|
|
6
|
+
from datetime import UTC, datetime
|
|
5
7
|
from pathlib import Path
|
|
6
8
|
|
|
7
9
|
import typer
|
|
10
|
+
from bashrun.bash import CalledProcessError, bash
|
|
8
11
|
from pydantic_settings import BaseSettings
|
|
9
12
|
|
|
10
|
-
from ci_devkit.cache import restore
|
|
13
|
+
from ci_devkit.cache import restore, save
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
class Settings(BaseSettings):
|
|
14
17
|
cache_registry: str
|
|
18
|
+
unity_email: str
|
|
19
|
+
unity_password: str
|
|
20
|
+
unity_serial: str
|
|
15
21
|
|
|
16
22
|
|
|
17
23
|
tag_app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
18
24
|
|
|
25
|
+
LICENSE_CACHE_NAME = "unity-license"
|
|
26
|
+
ACTIVATION_ATTEMPTS = 3
|
|
27
|
+
RETRY_JITTER_SECONDS = (30.0, 120.0)
|
|
28
|
+
|
|
19
29
|
|
|
20
30
|
@tag_app.command()
|
|
21
31
|
def tag_main() -> None:
|
|
22
32
|
print(license_cache_tag())
|
|
23
33
|
|
|
24
34
|
|
|
25
|
-
def
|
|
35
|
+
def restore_or_activate_license() -> None:
|
|
26
36
|
settings = Settings.model_validate({})
|
|
27
37
|
license_directory = Path.home() / ".local" / "share" / "unity3d" / "Unity"
|
|
28
38
|
license_directory.mkdir(parents=True, exist_ok=True)
|
|
29
|
-
|
|
39
|
+
tag = license_cache_tag()
|
|
40
|
+
|
|
41
|
+
for attempt in range(1, ACTIVATION_ATTEMPTS + 1):
|
|
42
|
+
if restore(settings.cache_registry, LICENSE_CACHE_NAME, tag, license_directory):
|
|
43
|
+
return
|
|
44
|
+
if license_activated():
|
|
45
|
+
save(settings.cache_registry, LICENSE_CACHE_NAME, tag, license_directory, ["Unity_lic.ulf"])
|
|
46
|
+
return
|
|
47
|
+
if attempt == ACTIVATION_ATTEMPTS:
|
|
48
|
+
break
|
|
49
|
+
wait = random.SystemRandom().uniform(*RETRY_JITTER_SECONDS)
|
|
50
|
+
print(
|
|
51
|
+
f"License activation rejected (attempt {attempt}/{ACTIVATION_ATTEMPTS}) — "
|
|
52
|
+
f"waiting {wait:.0f}s, then re-restoring and retrying"
|
|
53
|
+
)
|
|
54
|
+
time.sleep(wait)
|
|
55
|
+
|
|
56
|
+
raise SystemExit(
|
|
57
|
+
f"Unity license activation failed after {ACTIVATION_ATTEMPTS} attempts — "
|
|
58
|
+
"check UNITY_EMAIL/UNITY_PASSWORD/UNITY_SERIAL and the license seat"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def activate_license() -> None:
|
|
63
|
+
settings = Settings.model_validate({})
|
|
64
|
+
bash(
|
|
65
|
+
f'unity-editor -batchmode -nographics -quit -serial "{settings.unity_serial}"'
|
|
66
|
+
f' -username "{settings.unity_email}" -password "{settings.unity_password}" -logFile /dev/stdout'
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def license_activated() -> bool:
|
|
71
|
+
try:
|
|
72
|
+
activate_license()
|
|
73
|
+
except CalledProcessError:
|
|
74
|
+
return False
|
|
75
|
+
return True
|
|
30
76
|
|
|
31
77
|
|
|
32
78
|
# LICENSE_CACHE_TAG env pins the tag for a whole CI run; without it, each call
|
unity_devkit/matrix.py
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import json
|
|
2
4
|
from pathlib import Path
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
|
|
7
|
+
import typer
|
|
3
8
|
|
|
4
|
-
from .
|
|
9
|
+
from .license_restore import license_cache_tag
|
|
5
10
|
from .player_build import LICENSE_IMAGE_MODULE, PLATFORM_CONFIGS, UNITYCI_IMAGE_REVISION, read_editor_version
|
|
11
|
+
from .projects import ProjectEntry, discover_projects
|
|
6
12
|
|
|
13
|
+
build_app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
14
|
+
compile_check_app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
7
15
|
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
|
|
17
|
+
@build_app.command()
|
|
18
|
+
def build_matrix(
|
|
19
|
+
project: Annotated[
|
|
20
|
+
str | None, typer.Option(help="Restrict the matrix to one project (dispatch scoping in multi-app repos)")
|
|
21
|
+
] = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
projects = filtered_projects(project)
|
|
10
24
|
matrix: list[dict[str, str]] = []
|
|
11
|
-
editor_versions: set[str] = set()
|
|
12
25
|
|
|
13
|
-
for name,
|
|
14
|
-
if not
|
|
26
|
+
for name, entry in projects.items():
|
|
27
|
+
if not entry.builds:
|
|
15
28
|
continue
|
|
16
|
-
version = read_editor_version(
|
|
17
|
-
|
|
18
|
-
for platform in project.builds:
|
|
29
|
+
version = read_editor_version(entry.path)
|
|
30
|
+
for platform in entry.builds:
|
|
19
31
|
image_module = PLATFORM_CONFIGS[platform]["unityci_image_module"]
|
|
20
32
|
matrix.append({
|
|
21
|
-
"project": str(
|
|
33
|
+
"project": str(entry.path.relative_to(Path.cwd())),
|
|
22
34
|
"project-name": name,
|
|
23
35
|
"cache-key": name.lower(),
|
|
24
36
|
"platform": platform,
|
|
@@ -26,27 +38,39 @@ def build_matrix() -> None:
|
|
|
26
38
|
"editor-image": f"unityci/editor:{version}-{image_module}-{UNITYCI_IMAGE_REVISION}",
|
|
27
39
|
})
|
|
28
40
|
|
|
29
|
-
if not
|
|
41
|
+
if not matrix:
|
|
30
42
|
raise SystemExit(
|
|
31
|
-
"No projects with builds declared — build-unity-matrix needs at least one unity-devkit.json
|
|
43
|
+
"No projects with builds declared — build-unity-matrix needs at least one unity-devkit.json "
|
|
44
|
+
"with a non-empty 'platforms' map"
|
|
32
45
|
)
|
|
33
|
-
license_version = max(editor_versions)
|
|
34
46
|
print(f"matrix={json.dumps({'include': matrix})}")
|
|
35
|
-
print(f"license-
|
|
47
|
+
print(f"license-tag={license_cache_tag()}")
|
|
36
48
|
|
|
37
49
|
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
@compile_check_app.command()
|
|
51
|
+
def compile_check_matrix(
|
|
52
|
+
project: Annotated[
|
|
53
|
+
str | None, typer.Option(help="Restrict the matrix to one project (dispatch scoping in multi-app repos)")
|
|
54
|
+
] = None,
|
|
55
|
+
) -> None:
|
|
56
|
+
projects = filtered_projects(project)
|
|
40
57
|
matrix: list[dict[str, str]] = []
|
|
41
|
-
editor_versions: set[str] = set()
|
|
42
58
|
|
|
43
|
-
for name,
|
|
44
|
-
version = read_editor_version(
|
|
45
|
-
editor_versions.add(version)
|
|
59
|
+
for name, entry in projects.items():
|
|
60
|
+
version = read_editor_version(entry.path)
|
|
46
61
|
matrix.append({
|
|
47
62
|
"project-name": name,
|
|
48
63
|
"editor-image": f"unityci/editor:{version}-{LICENSE_IMAGE_MODULE}-{UNITYCI_IMAGE_REVISION}",
|
|
49
64
|
})
|
|
50
65
|
|
|
51
66
|
print(f"matrix={json.dumps({'include': matrix})}")
|
|
52
|
-
print(f"license-
|
|
67
|
+
print(f"license-tag={license_cache_tag()}")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def filtered_projects(project: str | None) -> dict[str, ProjectEntry]:
|
|
71
|
+
projects = discover_projects()
|
|
72
|
+
if project is None:
|
|
73
|
+
return projects
|
|
74
|
+
if project not in projects:
|
|
75
|
+
raise SystemExit(f"Unknown project '{project}'. Valid: {', '.join(projects)}")
|
|
76
|
+
return {project: projects[project]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from pydantic_settings import BaseSettings
|
|
7
|
+
|
|
8
|
+
from ci_devkit.cache import restore, save
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Settings(BaseSettings):
|
|
12
|
+
cache_registry: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
UPM_CACHE_NAME = "unity-upm"
|
|
16
|
+
UPM_CACHE_DIRECTORY = Path.home() / ".cache" / "Unity" / "upm"
|
|
17
|
+
UPM_MANIFESTS = ("manifest.json", "packages-lock.json")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def restore_upm_cache(project_path: Path) -> None:
|
|
21
|
+
settings = Settings.model_validate({})
|
|
22
|
+
UPM_CACHE_DIRECTORY.mkdir(parents=True, exist_ok=True)
|
|
23
|
+
restore(settings.cache_registry, UPM_CACHE_NAME, upm_cache_tag(project_path), UPM_CACHE_DIRECTORY)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def save_upm_cache(project_path: Path) -> None:
|
|
27
|
+
settings = Settings.model_validate({})
|
|
28
|
+
UPM_CACHE_DIRECTORY.mkdir(parents=True, exist_ok=True)
|
|
29
|
+
save(settings.cache_registry, UPM_CACHE_NAME, upm_cache_tag(project_path), UPM_CACHE_DIRECTORY, ["."])
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# A never-resolved project has no packages-lock.json yet; hashing it as empty keeps the
|
|
33
|
+
# tag computable, and the lock written by that run produces the tag the next run restores.
|
|
34
|
+
def upm_cache_tag(project_path: Path) -> str:
|
|
35
|
+
digest = hashlib.sha256()
|
|
36
|
+
for name in UPM_MANIFESTS:
|
|
37
|
+
manifest = project_path / "Packages" / name
|
|
38
|
+
digest.update(manifest.read_bytes() if manifest.exists() else b"")
|
|
39
|
+
return digest.hexdigest()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
unity_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
unity_devkit/build_unity.py,sha256=gYkfbMqZJ43DMvpRhp9WZ1zdkJhpRJ2uBXI2bGdIoGo,1545
|
|
3
|
+
unity_devkit/ci_build_unity.py,sha256=YiVuhNBmdkOGqSHNe2peUGVfR9WZTyv8NjLiI5DyR0Q,5698
|
|
4
|
+
unity_devkit/compile_check_unity.py,sha256=-F9GKjQ8x-_LQfDaCusxcn5V-1zh140dgzz9QitJnzk,1869
|
|
5
|
+
unity_devkit/install.py,sha256=_1KaJ4q0TYMBG8Eg3Ak6EBLDxcNKFF-CqC1II1nqO-0,7810
|
|
6
|
+
unity_devkit/license.py,sha256=nSE3Mn-irTbjom7BOgJf6d8X-O3o7WT8ZJ8XSdhAGVU,828
|
|
7
|
+
unity_devkit/license_restore.py,sha256=MMu1duRf_fXw3nbn5-Nsja9BlQXp24RNB69RiOeEOhM,2529
|
|
8
|
+
unity_devkit/lock_unity.py,sha256=-1d-mHva5XUOlki8LSO5qwABR52q7jzc7FTJnnTH9f8,1012
|
|
9
|
+
unity_devkit/matrix.py,sha256=jCi0bMMncFPNWDyGHa48CBz84jCkt70MZ5est6StXLk,2729
|
|
10
|
+
unity_devkit/player_build.py,sha256=AT6sZ1IoMzzRh0ECKcRL2YC1WrLqP7Kq7gGC0HRq8Iw,9914
|
|
11
|
+
unity_devkit/projects.py,sha256=PO5plIj-mn8KkKOUhGRRIL_sDdd6ohl12neS2poILhs,2665
|
|
12
|
+
unity_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
unity_devkit/test_unity.py,sha256=SpeWnV2hpdZBaGsstL8RTO50C2HEAcvantzBQYeaTpE,1075
|
|
14
|
+
unity_devkit/upm_cache.py,sha256=3TgGjweDj0R8ca_xz25v91lxnguNLBcIn6wKmmvhb_U,1331
|
|
15
|
+
unity_devkit-0.1.21.dist-info/METADATA,sha256=xeAe8ZpI23bh_q1LuVVoJKx7cnf3LoIM3xMttToBwyw,290
|
|
16
|
+
unity_devkit-0.1.21.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
17
|
+
unity_devkit-0.1.21.dist-info/entry_points.txt,sha256=ma3InxWKmFwqjQ7e2bJV5cxgH3GYoU2m9wEAvVHczUI,520
|
|
18
|
+
unity_devkit-0.1.21.dist-info/RECORD,,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
[console_scripts]
|
|
2
2
|
activate-unity-license = unity_devkit.license:activate_app
|
|
3
3
|
build-unity = unity_devkit.build_unity:app
|
|
4
|
-
build-unity-matrix = unity_devkit.matrix:
|
|
4
|
+
build-unity-matrix = unity_devkit.matrix:build_app
|
|
5
5
|
ci-build-unity = unity_devkit.ci_build_unity:app
|
|
6
6
|
compile-check-unity = unity_devkit.compile_check_unity:app
|
|
7
|
-
compile-check-unity-matrix = unity_devkit.matrix:
|
|
7
|
+
compile-check-unity-matrix = unity_devkit.matrix:compile_check_app
|
|
8
8
|
install = unity_devkit.install:app
|
|
9
9
|
lock-unity = unity_devkit.lock_unity:app
|
|
10
10
|
test-unity = unity_devkit.test_unity:app
|
|
11
|
-
unity-dispatch = unity_devkit.dispatch_workflow_generator:app
|
|
12
11
|
unity-license-tag = unity_devkit.license_restore:tag_app
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from collections import Counter
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Annotated
|
|
5
|
-
|
|
6
|
-
import typer
|
|
7
|
-
from pydantic import BaseModel, ConfigDict
|
|
8
|
-
|
|
9
|
-
from .compile_check_unity import COMPILE_ERROR_SIGNATURES
|
|
10
|
-
from .projects import discover_projects
|
|
11
|
-
from .player_build import prepare_unity_project, run_unity_batchmode
|
|
12
|
-
|
|
13
|
-
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
14
|
-
|
|
15
|
-
DUMP_EXECUTE_METHOD = "Outernet.PlayerBuild.DumpEnvironment"
|
|
16
|
-
DISPATCH_INPUT_CAP = 25
|
|
17
|
-
RESERVED_INPUT_IDS = frozenset({"environment-preset", "development"})
|
|
18
|
-
NUMERIC_FIELD_TYPES = {
|
|
19
|
-
"Byte",
|
|
20
|
-
"SByte",
|
|
21
|
-
"Int16",
|
|
22
|
-
"UInt16",
|
|
23
|
-
"Int32",
|
|
24
|
-
"UInt32",
|
|
25
|
-
"Int64",
|
|
26
|
-
"UInt64",
|
|
27
|
-
"Single",
|
|
28
|
-
"Double",
|
|
29
|
-
"Decimal",
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class EnvironmentEnum(BaseModel):
|
|
34
|
-
model_config = ConfigDict(extra="forbid")
|
|
35
|
-
|
|
36
|
-
name: str
|
|
37
|
-
values: list[str]
|
|
38
|
-
flags: bool
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class EnvironmentFieldDump(BaseModel):
|
|
42
|
-
model_config = ConfigDict(extra="forbid")
|
|
43
|
-
|
|
44
|
-
path: str
|
|
45
|
-
field_type: str
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class EnvironmentDump(BaseModel):
|
|
49
|
-
model_config = ConfigDict(extra="forbid")
|
|
50
|
-
|
|
51
|
-
class_name: str
|
|
52
|
-
mode_field: str
|
|
53
|
-
target_path: str
|
|
54
|
-
presets: dict[str, str]
|
|
55
|
-
enums: list[EnvironmentEnum]
|
|
56
|
-
fields: list[EnvironmentFieldDump]
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@app.command()
|
|
60
|
-
def unity_dispatch(
|
|
61
|
-
project: Annotated[str, typer.Option(help="Unity project name (the 'name' field of its unity-devkit.json)")],
|
|
62
|
-
output: Annotated[Path, typer.Option(help="Workflow file to write (or check with --check)")],
|
|
63
|
-
build_workflow: Annotated[
|
|
64
|
-
str,
|
|
65
|
-
typer.Option(
|
|
66
|
-
help="The build job's uses: value — the consumer's pinned build-unity.yml reference "
|
|
67
|
-
"(owner/repo/.github/workflows/build-unity.yml@sha, or ./.github/workflows/build-unity.yml inside unity-devkit)"
|
|
68
|
-
),
|
|
69
|
-
],
|
|
70
|
-
environment_config_class: Annotated[
|
|
71
|
-
str | None,
|
|
72
|
-
typer.Option(help="Env class file path override (defaults to unity-devkit.json's environment_config)"),
|
|
73
|
-
] = None,
|
|
74
|
-
check: Annotated[
|
|
75
|
-
bool, typer.Option("--check", help="Compare against the existing file instead of writing; fail on drift")
|
|
76
|
-
] = False,
|
|
77
|
-
) -> None:
|
|
78
|
-
projects = discover_projects()
|
|
79
|
-
if project not in projects:
|
|
80
|
-
raise SystemExit(f"Unknown project '{project}'. Valid: {', '.join(projects)}")
|
|
81
|
-
|
|
82
|
-
project_path = projects[project].path
|
|
83
|
-
env = {"ENVIRONMENT_CONFIG_CLASS": environment_config_class} if environment_config_class else None
|
|
84
|
-
print(f"Dumping environment of {project}...")
|
|
85
|
-
prepare_unity_project(project_path)
|
|
86
|
-
log_path = run_unity_batchmode(
|
|
87
|
-
project_path,
|
|
88
|
-
f"-executeMethod {DUMP_EXECUTE_METHOD}",
|
|
89
|
-
extra_failure_signatures=COMPILE_ERROR_SIGNATURES,
|
|
90
|
-
env=env,
|
|
91
|
-
)
|
|
92
|
-
dump = extract_environment_dump(log_path)
|
|
93
|
-
workflow = render_dispatch_workflow(dump, project=project, output=output.as_posix(), build_workflow=build_workflow)
|
|
94
|
-
|
|
95
|
-
if check:
|
|
96
|
-
if not output.is_file():
|
|
97
|
-
raise SystemExit(f"Dispatch workflow drift: {output} does not exist — generate it")
|
|
98
|
-
committed = output.read_text(encoding="utf-8")
|
|
99
|
-
if committed != workflow:
|
|
100
|
-
raise SystemExit(
|
|
101
|
-
f"Dispatch workflow drift: {output} differs from the environment class — regenerate with "
|
|
102
|
-
f"'{regen_command(project, output.as_posix(), build_workflow)}'"
|
|
103
|
-
)
|
|
104
|
-
print(f" {output} matches the environment class")
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
output.parent.mkdir(parents=True, exist_ok=True)
|
|
108
|
-
output.write_text(workflow, encoding="utf-8")
|
|
109
|
-
print(f" wrote {output}")
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def extract_environment_dump(log_path: Path) -> EnvironmentDump:
|
|
113
|
-
for line in log_path.read_text(encoding="utf-8", errors="replace").splitlines():
|
|
114
|
-
candidate = line.strip()
|
|
115
|
-
if not candidate.startswith("{"):
|
|
116
|
-
continue
|
|
117
|
-
try:
|
|
118
|
-
payload = json.loads(candidate)
|
|
119
|
-
except json.JSONDecodeError:
|
|
120
|
-
continue
|
|
121
|
-
if isinstance(payload, dict) and "class_name" in payload:
|
|
122
|
-
return EnvironmentDump.model_validate(payload)
|
|
123
|
-
|
|
124
|
-
raise SystemExit(f"No environment dump JSON found in the editor log at {log_path}")
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def render_dispatch_workflow(dump: EnvironmentDump, *, project: str, output: str, build_workflow: str) -> str:
|
|
128
|
-
enums_by_name = {environment_enum.name: environment_enum for environment_enum in dump.enums}
|
|
129
|
-
emitted_fields = [field for field in dump.fields if field.path != dump.mode_field]
|
|
130
|
-
leaf_counts = Counter(field.path.rsplit(".", 1)[-1] for field in emitted_fields)
|
|
131
|
-
input_ids: dict[str, str] = {}
|
|
132
|
-
for field in emitted_fields:
|
|
133
|
-
leaf = field.path.rsplit(".", 1)[-1]
|
|
134
|
-
input_ids[field.path] = (
|
|
135
|
-
leaf if leaf_counts[leaf] == 1 and leaf not in RESERVED_INPUT_IDS else field.path.replace(".", "-")
|
|
136
|
-
)
|
|
137
|
-
default_preset = next(iter(dump.presets), "")
|
|
138
|
-
input_blocks: list[tuple[str, str | None, list[str], str | None]] = [
|
|
139
|
-
(
|
|
140
|
-
"environment-preset",
|
|
141
|
-
"Preset to apply — blank leaves the workspace untouched; leave fields empty to keep the preset's values",
|
|
142
|
-
["type: choice", "options:", *indent_lines([*(f'- "{preset}"' for preset in ("", *dump.presets))], 2)],
|
|
143
|
-
f'default: "{default_preset}"',
|
|
144
|
-
),
|
|
145
|
-
("development", "Development build (debug symbols)", ["type: boolean"], "default: false"),
|
|
146
|
-
]
|
|
147
|
-
for field in emitted_fields:
|
|
148
|
-
input_blocks.append(field_input_block(field, input_ids[field.path], enums_by_name))
|
|
149
|
-
|
|
150
|
-
input_count = len(input_blocks)
|
|
151
|
-
if input_count > DISPATCH_INPUT_CAP:
|
|
152
|
-
raise SystemExit(
|
|
153
|
-
f"Dispatch panel would carry {input_count} inputs — GitHub's workflow_dispatch cap is {DISPATCH_INPUT_CAP}. "
|
|
154
|
-
"Shrink the env class or move configuration out of it."
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
transport_lines = [field_transport_line(field, input_ids[field.path]) for field in emitted_fields]
|
|
158
|
-
header = (
|
|
159
|
-
f"# Generated by '{regen_command(project, output, build_workflow)}' from the environment class "
|
|
160
|
-
f"{dump.class_name} —"
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
lines = [
|
|
164
|
-
header,
|
|
165
|
-
"# edit the class, then regenerate this workflow.",
|
|
166
|
-
"name: Unity Dispatch Build",
|
|
167
|
-
"",
|
|
168
|
-
"on:",
|
|
169
|
-
" workflow_dispatch:",
|
|
170
|
-
" inputs:",
|
|
171
|
-
*indent_lines([line for block in input_blocks for line in build_input_block(block)], 6),
|
|
172
|
-
"",
|
|
173
|
-
"jobs:",
|
|
174
|
-
" build:",
|
|
175
|
-
f" uses: {build_workflow}",
|
|
176
|
-
" with:",
|
|
177
|
-
" environment-preset: ${{ inputs['environment-preset'] }}",
|
|
178
|
-
" development: ${{ inputs.development }}",
|
|
179
|
-
]
|
|
180
|
-
if transport_lines:
|
|
181
|
-
lines.append(" environment-fields: |-")
|
|
182
|
-
lines.extend(indent_lines(transport_lines, 8))
|
|
183
|
-
else:
|
|
184
|
-
lines.append(" environment-fields: ''")
|
|
185
|
-
lines.append(" secrets: inherit")
|
|
186
|
-
return "\n".join(lines) + "\n"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
def regen_command(project: str, output: str, build_workflow: str) -> str:
|
|
190
|
-
return f"uv run unity-dispatch --project {project} --output {output} --build-workflow {build_workflow}"
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def field_input_block(
|
|
194
|
-
field: EnvironmentFieldDump, input_id: str, enums_by_name: dict[str, EnvironmentEnum]
|
|
195
|
-
) -> tuple[str, str | None, list[str], str | None]:
|
|
196
|
-
if field.field_type == "Boolean":
|
|
197
|
-
return (input_id, None, ["type: boolean"], "default: false")
|
|
198
|
-
|
|
199
|
-
if field.field_type in enums_by_name:
|
|
200
|
-
environment_enum = enums_by_name[field.field_type]
|
|
201
|
-
if environment_enum.flags:
|
|
202
|
-
return (
|
|
203
|
-
input_id,
|
|
204
|
-
f"comma-separated: {', '.join(environment_enum.values)}",
|
|
205
|
-
["type: string"],
|
|
206
|
-
'default: ""',
|
|
207
|
-
)
|
|
208
|
-
return (
|
|
209
|
-
input_id,
|
|
210
|
-
None,
|
|
211
|
-
[
|
|
212
|
-
"type: choice",
|
|
213
|
-
"options:",
|
|
214
|
-
*indent_lines([*(f'- "{value}"' for value in ("", *environment_enum.values))], 2),
|
|
215
|
-
],
|
|
216
|
-
'default: ""',
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
if field.field_type == "String":
|
|
220
|
-
return (input_id, None, ["type: string"], 'default: ""')
|
|
221
|
-
|
|
222
|
-
if field.field_type in NUMERIC_FIELD_TYPES:
|
|
223
|
-
return (input_id, None, ["type: number"], None)
|
|
224
|
-
|
|
225
|
-
raise SystemExit(
|
|
226
|
-
f"Environment field '{field.path}' has type '{field.field_type}' — no dispatch input type maps to it "
|
|
227
|
-
"(arrays and object references self-exclude from the dump; this is contract drift)"
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
def field_transport_line(field: EnvironmentFieldDump, input_id: str) -> str:
|
|
232
|
-
guard = "" if field.field_type == "Boolean" else " != ''"
|
|
233
|
-
return (
|
|
234
|
-
"${{ inputs['"
|
|
235
|
-
+ input_id
|
|
236
|
-
+ "']"
|
|
237
|
-
+ guard
|
|
238
|
-
+ " && format('"
|
|
239
|
-
+ field.path
|
|
240
|
-
+ "={0}', inputs['"
|
|
241
|
-
+ input_id
|
|
242
|
-
+ "']) || '' }}"
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
def build_input_block(input_block: tuple[str, str | None, list[str], str | None]) -> list[str]:
|
|
247
|
-
input_id, description, type_lines, default_line = input_block
|
|
248
|
-
lines = [f"{input_id}:"]
|
|
249
|
-
if description is not None:
|
|
250
|
-
lines.append(f' description: "{description}"')
|
|
251
|
-
lines.extend(f" {line}" for line in type_lines)
|
|
252
|
-
if default_line is not None:
|
|
253
|
-
lines.append(f" {default_line}")
|
|
254
|
-
return lines
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
def indent_lines(lines: list[str], spaces: int) -> list[str]:
|
|
258
|
-
return [f"{' ' * spaces}{line}" if line else line for line in lines]
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
unity_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
unity_devkit/build_unity.py,sha256=gYkfbMqZJ43DMvpRhp9WZ1zdkJhpRJ2uBXI2bGdIoGo,1545
|
|
3
|
-
unity_devkit/ci_build_unity.py,sha256=31-fa-tWVx5JqIJ9isQpoal9MUlFCSa9pO8JORUjbdk,5310
|
|
4
|
-
unity_devkit/compile_check_unity.py,sha256=WHg0YztiYes37dvnZrTNcUFO5T0MLSx_cCvA85wvr9k,1236
|
|
5
|
-
unity_devkit/dispatch_workflow_generator.py,sha256=l85pGXl7XgHIzDJQmhFwuYONm5sz_90ziNE_8aQqhpM,9305
|
|
6
|
-
unity_devkit/install.py,sha256=_1KaJ4q0TYMBG8Eg3Ak6EBLDxcNKFF-CqC1II1nqO-0,7810
|
|
7
|
-
unity_devkit/license.py,sha256=iiMdos8kMk4p5uYYroIWUzxvusXtcMRdPkIDXsYTC9c,1484
|
|
8
|
-
unity_devkit/license_restore.py,sha256=Tbt2Kt1axszqj4H6K5Fx9_nqRL-dpL5XTVnxnmP4PZw,1077
|
|
9
|
-
unity_devkit/lock_unity.py,sha256=-1d-mHva5XUOlki8LSO5qwABR52q7jzc7FTJnnTH9f8,1012
|
|
10
|
-
unity_devkit/matrix.py,sha256=3fiHxkVyNFfCKzQRMXSo5c2P1tDHn0XteZXV-mQ8cxk,2057
|
|
11
|
-
unity_devkit/player_build.py,sha256=AT6sZ1IoMzzRh0ECKcRL2YC1WrLqP7Kq7gGC0HRq8Iw,9914
|
|
12
|
-
unity_devkit/projects.py,sha256=PO5plIj-mn8KkKOUhGRRIL_sDdd6ohl12neS2poILhs,2665
|
|
13
|
-
unity_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
unity_devkit/test_unity.py,sha256=SpeWnV2hpdZBaGsstL8RTO50C2HEAcvantzBQYeaTpE,1075
|
|
15
|
-
unity_devkit-0.1.19.dist-info/METADATA,sha256=2Uhmb0KjP_ZKfPFT7oCQv7oTQF-PyOeJlhkrPdxXQg0,290
|
|
16
|
-
unity_devkit-0.1.19.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
17
|
-
unity_devkit-0.1.19.dist-info/entry_points.txt,sha256=wdkAD7hjUPC4tDwe1ulAo5a0vWPXPO5sSGX1iN6VvJc,588
|
|
18
|
-
unity_devkit-0.1.19.dist-info/RECORD,,
|
|
File without changes
|