sdk-release-kit 0.2.0__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.
Files changed (39) hide show
  1. sdk_release_kit/__init__.py +3 -0
  2. sdk_release_kit/_data/examples/custom.example.yaml +18 -0
  3. sdk_release_kit/_data/examples/keys.example.yaml +18 -0
  4. sdk_release_kit/_data/examples/outputs.example.yaml +19 -0
  5. sdk_release_kit/_data/examples/repos.example.yaml +33 -0
  6. sdk_release_kit/_data/recipes/sdks.yaml +222 -0
  7. sdk_release_kit/_data/web/app.js +305 -0
  8. sdk_release_kit/_data/web/index.html +142 -0
  9. sdk_release_kit/_data/web/styles.css +93 -0
  10. sdk_release_kit/builders/__init__.py +24 -0
  11. sdk_release_kit/builders/android.py +86 -0
  12. sdk_release_kit/builders/base.py +217 -0
  13. sdk_release_kit/builders/flutter.py +16 -0
  14. sdk_release_kit/builders/generic.py +56 -0
  15. sdk_release_kit/builders/ios.py +204 -0
  16. sdk_release_kit/builders/reactnative.py +32 -0
  17. sdk_release_kit/cli.py +198 -0
  18. sdk_release_kit/mcp_server.py +240 -0
  19. sdk_release_kit/models.py +306 -0
  20. sdk_release_kit/paths.py +85 -0
  21. sdk_release_kit/pipeline.py +446 -0
  22. sdk_release_kit/recipes.py +110 -0
  23. sdk_release_kit/runlog.py +62 -0
  24. sdk_release_kit/server.py +331 -0
  25. sdk_release_kit/store/__init__.py +29 -0
  26. sdk_release_kit/store/_yaml.py +46 -0
  27. sdk_release_kit/store/custom.py +34 -0
  28. sdk_release_kit/store/keys.py +111 -0
  29. sdk_release_kit/store/outputs.py +15 -0
  30. sdk_release_kit/store/repos.py +15 -0
  31. sdk_release_kit/uploaders/__init__.py +20 -0
  32. sdk_release_kit/uploaders/onedrive.py +129 -0
  33. sdk_release_kit/uploaders/play.py +108 -0
  34. sdk_release_kit/uploaders/testflight.py +105 -0
  35. sdk_release_kit-0.2.0.dist-info/METADATA +307 -0
  36. sdk_release_kit-0.2.0.dist-info/RECORD +39 -0
  37. sdk_release_kit-0.2.0.dist-info/WHEEL +4 -0
  38. sdk_release_kit-0.2.0.dist-info/entry_points.txt +2 -0
  39. sdk_release_kit-0.2.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,306 @@
1
+ """Typed schemas for recipes (shipped in git) and user settings (kept on this machine).
2
+
3
+ Compatibility rules:
4
+ * Every file carries ``schema_version``. Bump it only for breaking changes and add a migration.
5
+ * Settings models allow unknown keys (``extra="allow"``) so values written by a newer version
6
+ or by hand are preserved on save.
7
+ * Recipe models forbid unknown keys so typos in ``recipes/sdks.yaml`` fail loudly.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from typing import Annotated, Any, Literal
13
+
14
+ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
15
+
16
+ SCHEMA_VERSION = 1
17
+
18
+ Destination = Literal["onedrive", "play", "testflight"]
19
+ DESTINATIONS: tuple[str, ...] = ("onedrive", "play", "testflight")
20
+ ArtifactSelection = Literal["demos", "packages", "both"]
21
+ ArtifactKind = Literal[
22
+ "apk", "aab", "ipa", "app", "aar", "jar", "zip", "tgz", "xcframework", "framework", "other"
23
+ ]
24
+
25
+
26
+ class _Settings(BaseModel):
27
+ model_config = ConfigDict(extra="allow", validate_assignment=True)
28
+
29
+
30
+ class _Recipe(BaseModel):
31
+ model_config = ConfigDict(extra="forbid")
32
+
33
+
34
+ # --------------------------------------------------------------------------------------------
35
+ # User settings
36
+ # --------------------------------------------------------------------------------------------
37
+
38
+
39
+ class RepoEntry(_Settings):
40
+ path: str = ""
41
+ enabled: bool = True
42
+
43
+
44
+ class Tooling(_Settings):
45
+ java_home: str | None = None
46
+ android_sdk: str | None = None
47
+ flutter_bin: str | None = None
48
+ developer_dir: str | None = Field(
49
+ default=None, description="Optional DEVELOPER_DIR to pick a specific Xcode."
50
+ )
51
+ extra_path: list[str] = Field(default_factory=list)
52
+
53
+
54
+ class ReposSettings(_Settings):
55
+ schema_version: int = SCHEMA_VERSION
56
+ repos: dict[str, RepoEntry] = Field(default_factory=dict)
57
+ tooling: Tooling = Field(default_factory=Tooling)
58
+
59
+ @field_validator("repos", mode="before")
60
+ @classmethod
61
+ def _accept_plain_paths(cls, value: Any) -> Any:
62
+ if isinstance(value, dict):
63
+ return {
64
+ k: ({"path": v} if isinstance(v, str) or v is None else v) for k, v in value.items()
65
+ }
66
+ return value
67
+
68
+
69
+ class OneDriveOutput(_Settings):
70
+ enabled: bool = False
71
+ root: str | None = None
72
+ demos_android: str = "android"
73
+ demos_ios: str = "ios"
74
+ packages: str = "packages"
75
+ copy_untargeted: bool = Field(
76
+ default=False,
77
+ description="Also copy demo artifacts that have no target id, under <folder>/<recipe-id>/.",
78
+ )
79
+
80
+
81
+ class PlayOutput(_Settings):
82
+ enabled: bool = False
83
+ track: str = "internal"
84
+ release_status: Literal["completed", "draft"] = "completed"
85
+ method: Literal["auto", "api", "fastlane"] = "auto"
86
+
87
+
88
+ class TestFlightOutput(_Settings):
89
+ enabled: bool = False
90
+ method: Literal["altool", "fastlane"] = "altool"
91
+
92
+
93
+ class OutputsSettings(_Settings):
94
+ schema_version: int = SCHEMA_VERSION
95
+ staging: str = "~/sdk-release-kit/staging"
96
+ onedrive: OneDriveOutput = Field(default_factory=OneDriveOutput)
97
+ play: PlayOutput = Field(default_factory=PlayOutput)
98
+ testflight: TestFlightOutput = Field(default_factory=TestFlightOutput)
99
+
100
+
101
+ class SecretRef(_Settings):
102
+ """Points at a secret without containing it."""
103
+
104
+ source: Literal["none", "env", "keychain"] = "none"
105
+ name: str = ""
106
+
107
+ @property
108
+ def is_set(self) -> bool:
109
+ return self.source != "none" and bool(self.name)
110
+
111
+
112
+ class AndroidKeys(_Settings):
113
+ keystore_path: str | None = None
114
+ key_alias: str | None = None
115
+ store_password: SecretRef = Field(
116
+ default_factory=lambda: SecretRef(source="keychain", name="android.store_password")
117
+ )
118
+ key_password: SecretRef = Field(
119
+ default_factory=lambda: SecretRef(source="keychain", name="android.key_password")
120
+ )
121
+ inject_signing: bool = Field(
122
+ default=True,
123
+ description="Pass signing to Gradle via android.injected.signing.* properties.",
124
+ )
125
+
126
+
127
+ class PlayKeys(_Settings):
128
+ json_key_path: str | None = None
129
+
130
+
131
+ class TestFlightKeys(_Settings):
132
+ key_id: SecretRef = Field(default_factory=lambda: SecretRef(source="env", name="ASC_KEY_ID"))
133
+ issuer_id: SecretRef = Field(
134
+ default_factory=lambda: SecretRef(source="env", name="ASC_ISSUER_ID")
135
+ )
136
+ key_path: str | None = None
137
+
138
+
139
+ class KeysSettings(_Settings):
140
+ schema_version: int = SCHEMA_VERSION
141
+ android: AndroidKeys = Field(default_factory=AndroidKeys)
142
+ play: PlayKeys = Field(default_factory=PlayKeys)
143
+ testflight: TestFlightKeys = Field(default_factory=TestFlightKeys)
144
+
145
+
146
+ # --------------------------------------------------------------------------------------------
147
+ # Recipes
148
+ # --------------------------------------------------------------------------------------------
149
+
150
+
151
+ class Collect(_Recipe):
152
+ glob: str
153
+ kind: ArtifactKind
154
+ target: str | None = Field(default=None, description="OneDrive target id for this artifact.")
155
+ root: str = Field(
156
+ default="workdir",
157
+ description="Glob root: workdir, repo, or a root the step exposes (e.g. derived_data).",
158
+ )
159
+ required: bool = True
160
+
161
+
162
+ class _StepBase(_Recipe):
163
+ name: str | None = None
164
+ workdir: str = "."
165
+ env: dict[str, str] = Field(default_factory=dict)
166
+ when: list[Destination] = Field(
167
+ default_factory=list,
168
+ description="Run only if one of these destinations is active. Empty means always.",
169
+ )
170
+ host: Literal["any", "macos"] = "any"
171
+ collect: list[Collect] = Field(default_factory=list)
172
+
173
+
174
+ class RunStep(_StepBase):
175
+ type: Literal["run"]
176
+ cmd: str | list[str]
177
+
178
+
179
+ class GradleStep(_StepBase):
180
+ type: Literal["gradle"]
181
+ tasks: list[str]
182
+ args: list[str] = Field(default_factory=lambda: ["--console=plain"])
183
+ sign: bool = True
184
+
185
+
186
+ class FlutterStep(_StepBase):
187
+ type: Literal["flutter"]
188
+ args: list[str]
189
+ sign: bool = True
190
+
191
+
192
+ class _XcodeBase(_StepBase):
193
+ host: Literal["any", "macos"] = "macos"
194
+ workspace: str | None = None
195
+ project: str | None = None
196
+ scheme: str
197
+ pod_install: bool = False
198
+
199
+ @model_validator(mode="after")
200
+ def _one_container(self) -> _XcodeBase:
201
+ if self.workspace and self.project:
202
+ raise ValueError("set either workspace or project, not both")
203
+ return self
204
+
205
+
206
+ class XcodeSimulatorStep(_XcodeBase):
207
+ type: Literal["xcode-simulator"]
208
+ configuration: str = "Debug"
209
+ app_name: str | None = Field(default=None, description="Product .app name if not obvious.")
210
+ target: str | None = Field(default=None, description="OneDrive target id for the .app.")
211
+
212
+
213
+ class XcodeIpaStep(_XcodeBase):
214
+ type: Literal["xcode-ipa"]
215
+ configuration: str = "Release"
216
+ export_method: str = "app-store-connect"
217
+ team_id: str | None = None
218
+
219
+
220
+ class XcframeworkStep(_XcodeBase):
221
+ type: Literal["xcframework"]
222
+ framework_name: str
223
+ configuration: str = "Release"
224
+
225
+
226
+ class NpmPackStep(_StepBase):
227
+ type: Literal["npm-pack"]
228
+ install: bool = False
229
+
230
+
231
+ class SourceZipStep(_StepBase):
232
+ type: Literal["source-zip"]
233
+ method: Literal["git-archive", "files"] = "git-archive"
234
+ exclude: list[str] = Field(
235
+ default_factory=lambda: [
236
+ ".git",
237
+ "build",
238
+ ".dart_tool",
239
+ ".gradle",
240
+ "node_modules",
241
+ "Pods",
242
+ ".idea",
243
+ "DerivedData",
244
+ ]
245
+ )
246
+
247
+
248
+ Step = Annotated[
249
+ RunStep
250
+ | GradleStep
251
+ | FlutterStep
252
+ | XcodeSimulatorStep
253
+ | XcodeIpaStep
254
+ | XcframeworkStep
255
+ | NpmPackStep
256
+ | SourceZipStep,
257
+ Field(discriminator="type"),
258
+ ]
259
+
260
+
261
+ class StoreFlags(_Recipe):
262
+ play: bool = False
263
+ testflight: bool = False
264
+ android_package: str | None = None
265
+ ios_bundle_id: str | None = None
266
+
267
+
268
+ class VersionSource(_Recipe):
269
+ file: str | None = None
270
+ regex: str | None = None
271
+ cmd: list[str] | None = None
272
+
273
+
274
+ class Recipe(_Recipe):
275
+ platform: str
276
+ label: str = ""
277
+ description: str = ""
278
+ version: VersionSource | None = None
279
+ store: StoreFlags = Field(default_factory=StoreFlags)
280
+ demos: list[Step] = Field(default_factory=list)
281
+ packages: list[Step] = Field(default_factory=list)
282
+
283
+
284
+ class OneDriveTarget(_Recipe):
285
+ folder: str = Field(
286
+ description="demos_android, demos_ios or packages (keys of outputs.onedrive)."
287
+ )
288
+ name: str
289
+
290
+
291
+ class RecipesFile(_Recipe):
292
+ schema_version: int = SCHEMA_VERSION
293
+ onedrive_targets: dict[str, OneDriveTarget] = Field(default_factory=dict)
294
+ recipes: dict[str, Recipe] = Field(default_factory=dict)
295
+
296
+ @model_validator(mode="after")
297
+ def _targets_exist(self) -> RecipesFile:
298
+ for rid, recipe in self.recipes.items():
299
+ for step in [*recipe.demos, *recipe.packages]:
300
+ targets = [c.target for c in step.collect]
301
+ if isinstance(step, XcodeSimulatorStep):
302
+ targets.append(step.target)
303
+ for t in targets:
304
+ if t and t not in self.onedrive_targets:
305
+ raise ValueError(f"recipe '{rid}' references unknown onedrive target '{t}'")
306
+ return self
@@ -0,0 +1,85 @@
1
+ """Resolve where things live.
2
+
3
+ Nothing in this module may contain a machine-specific absolute path. User data lives in an
4
+ OS config directory (or ``SDK_RELEASE_KIT_HOME``); shipped data lives next to the package.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ from pathlib import Path
11
+
12
+ APP_NAME = "sdk-release-kit"
13
+ SETTINGS_KINDS = ("repos", "outputs", "keys", "custom")
14
+
15
+ _PACKAGE_DIR = Path(__file__).resolve().parent
16
+
17
+
18
+ def user_home() -> Path:
19
+ """Directory holding this machine's settings. Never inside the git checkout."""
20
+ env = os.environ.get("SDK_RELEASE_KIT_HOME")
21
+ if env:
22
+ return Path(env).expanduser()
23
+ if os.name == "nt":
24
+ base = Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming")
25
+ else:
26
+ base = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config")
27
+ return base / APP_NAME
28
+
29
+
30
+ def settings_file(kind: str) -> Path:
31
+ """Path of one settings layer. ``SDK_RELEASE_KIT_<KIND>`` overrides it with a file path."""
32
+ if kind not in SETTINGS_KINDS:
33
+ raise ValueError(f"unknown settings kind: {kind}")
34
+ env = os.environ.get(f"SDK_RELEASE_KIT_{kind.upper()}")
35
+ if env:
36
+ return Path(env).expanduser()
37
+ return user_home() / f"{kind}.yaml"
38
+
39
+
40
+ def key_files_dir() -> Path:
41
+ """Where key files uploaded through the Settings UI are stored (mode 700)."""
42
+ return user_home() / "keys"
43
+
44
+
45
+ def recipe_overlay_dir() -> Path:
46
+ """Machine-local recipe overlays, deep-merged over the shipped recipes."""
47
+ return user_home() / "recipes.d"
48
+
49
+
50
+ def data_dir(name: str) -> Path:
51
+ """Shipped data (``recipes``, ``web``, ``examples``).
52
+
53
+ A wheel install carries them in ``sdk_release_kit/_data``; an editable install reads them
54
+ from the repository root.
55
+ """
56
+ packaged = _PACKAGE_DIR / "_data" / name
57
+ if packaged.is_dir():
58
+ return packaged
59
+ repo_root = _PACKAGE_DIR.parent.parent
60
+ candidate = repo_root / name
61
+ if candidate.is_dir():
62
+ return candidate
63
+ raise FileNotFoundError(f"shipped data directory '{name}' not found")
64
+
65
+
66
+ def expand(path: str | os.PathLike[str] | None) -> Path | None:
67
+ """Expand ``~`` and ``$VARS`` in a user-supplied path. Empty values become ``None``."""
68
+ if path is None:
69
+ return None
70
+ text = str(path).strip()
71
+ if not text:
72
+ return None
73
+ return Path(os.path.expandvars(os.path.expanduser(text)))
74
+
75
+
76
+ def safe_join(root: Path, relative: str) -> Path:
77
+ """Join a recipe-relative path to a repo root and refuse to leave the root."""
78
+ rel = Path(relative)
79
+ if rel.is_absolute():
80
+ raise ValueError(f"recipe paths must be relative, got '{relative}'")
81
+ joined = (root / rel).resolve()
82
+ root_resolved = root.resolve()
83
+ if joined != root_resolved and root_resolved not in joined.parents:
84
+ raise ValueError(f"recipe path '{relative}' escapes the repository root")
85
+ return joined