@daemux/store-automator 0.10.86 → 0.10.88
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/package.json +1 -1
- package/plugins/store-automator/.claude-plugin/plugin.json +1 -1
- package/templates/github/IOS_NATIVE_CI_SETUP.md +40 -18
- package/templates/scripts/ci/ios-native/auto_detect.py +274 -0
- package/templates/scripts/ci/ios-native/cfg_resolve.py +16 -125
- package/templates/scripts/ci/ios-native/read_config.py +144 -173
- package/templates/ios-native-ci.config.yaml.template +0 -30
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
},
|
|
6
6
|
"metadata": {
|
|
7
7
|
"description": "App Store & Google Play automation for Flutter apps",
|
|
8
|
-
"version": "0.10.
|
|
8
|
+
"version": "0.10.88"
|
|
9
9
|
},
|
|
10
10
|
"plugins": [
|
|
11
11
|
{
|
|
12
12
|
"name": "store-automator",
|
|
13
13
|
"source": "./plugins/store-automator",
|
|
14
14
|
"description": "3 agents for app store publishing: reviewer, meta-creator, media-designer",
|
|
15
|
-
"version": "0.10.
|
|
15
|
+
"version": "0.10.88",
|
|
16
16
|
"keywords": [
|
|
17
17
|
"flutter",
|
|
18
18
|
"app-store",
|
package/package.json
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
# iOS Native TestFlight CI — Setup Guide
|
|
2
2
|
|
|
3
|
-
Drop-in TestFlight automation for native Swift/SwiftUI iOS apps.
|
|
3
|
+
**Zero config.** Drop-in TestFlight automation for native Swift/SwiftUI iOS apps. Two files in your repo are all you need:
|
|
4
|
+
|
|
5
|
+
1. `.github/workflows/deploy.yml` (18 lines, copied verbatim)
|
|
6
|
+
2. `creds/AuthKey_<KEY_ID>_Issuer_<UUID>.p8` (your ASC API key)
|
|
7
|
+
|
|
8
|
+
There is **no** `ci.config.yaml`. The composite action auto-detects your project, workspace, scheme, bundle id, team id, and App Store Connect numeric app id from the Xcode project + ASC API. To override any auto-detected value, pass it via the action's `with:` block in `deploy.yml`.
|
|
9
|
+
|
|
10
|
+
All logic lives in the shared composite action `daemux/daemux-plugins/.github/actions/ios-native-testflight`.
|
|
4
11
|
|
|
5
12
|
## Prerequisites
|
|
6
13
|
|
|
7
14
|
- **Private GitHub repo** (holds the ASC API key `.p8` file).
|
|
8
15
|
- **Apple Developer Program** membership with an App Store Connect user that can create API keys.
|
|
9
16
|
- **ASC API Key** with `App Manager` role, downloaded as `AuthKey_<KEY_ID>.p8` (Apple lets you download this exactly once).
|
|
10
|
-
- Xcode project builds locally on macOS 15 / Xcode 16
|
|
17
|
+
- Xcode project builds locally on macOS 15 / Xcode 16+.
|
|
11
18
|
|
|
12
19
|
## Step 1 — Copy the workflow
|
|
13
20
|
|
|
14
21
|
Copy `.github/workflows/deploy.yml` verbatim from this template. No edits required. It triggers on push to `main` and via `workflow_dispatch`.
|
|
15
22
|
|
|
16
|
-
## Step 2 —
|
|
17
|
-
|
|
18
|
-
Copy `ios-native-ci.config.yaml.template` to your repo root as `ci.config.yaml`. Fill in:
|
|
19
|
-
|
|
20
|
-
- `app.bundle_id` — REQUIRED (must match your App Store Connect app record).
|
|
21
|
-
- `xcode.scheme` — REQUIRED (the shared scheme the CI should archive).
|
|
22
|
-
|
|
23
|
-
Every other field has a sensible default. `xcode.project` auto-detects if there is exactly one `*.xcodeproj` at the repo root. `app.app_store_apple_id` is auto-discovered via the ASC API from the bundle id.
|
|
24
|
-
|
|
25
|
-
## Step 3 — Drop in the ASC API key
|
|
23
|
+
## Step 2 — Drop in the ASC API key
|
|
26
24
|
|
|
27
25
|
Rename the downloaded key to include both the key id and the issuer uuid, then put it under `creds/`:
|
|
28
26
|
|
|
@@ -34,7 +32,7 @@ Example: `creds/AuthKey_5NBDY6YXJ6_Issuer_69a6de77-xxxx-xxxx-xxxx-xxxxxxxxxxxx.p
|
|
|
34
32
|
|
|
35
33
|
The composite action parses the key id and issuer id from the filename — no GitHub secrets to configure.
|
|
36
34
|
|
|
37
|
-
## Step
|
|
35
|
+
## Step 3 — Register the app in App Store Connect (one-time)
|
|
38
36
|
|
|
39
37
|
App Store Connect requires a human-in-the-loop 2FA step the first time. Either:
|
|
40
38
|
|
|
@@ -43,29 +41,53 @@ App Store Connect requires a human-in-the-loop 2FA step the first time. Either:
|
|
|
43
41
|
|
|
44
42
|
Subsequent builds need neither — the ASC API key handles everything.
|
|
45
43
|
|
|
46
|
-
## Step
|
|
44
|
+
## Step 4 — MARKETING_VERSION
|
|
47
45
|
|
|
48
46
|
Leave your Xcode project's `MARKETING_VERSION` at `1.0` initially. CI auto-rolls the marketing version forward (patch bump) whenever the prior version hits `READY_FOR_SALE` in App Store Connect. Until then, the pipeline keeps bumping the build number against the current marketing version.
|
|
49
47
|
|
|
50
|
-
## Step
|
|
48
|
+
## Step 5 — Push to `main`
|
|
51
49
|
|
|
52
50
|
```bash
|
|
53
|
-
git add .github/workflows/deploy.yml
|
|
51
|
+
git add .github/workflows/deploy.yml creds/AuthKey_*.p8
|
|
54
52
|
git commit -m "ci: add iOS TestFlight pipeline"
|
|
55
53
|
git push origin main
|
|
56
54
|
```
|
|
57
55
|
|
|
58
56
|
GitHub Actions triggers the workflow. On success, the build appears in TestFlight within 5–15 minutes (Apple processing delay).
|
|
59
57
|
|
|
58
|
+
## Overrides (optional)
|
|
59
|
+
|
|
60
|
+
If auto-detection picks the wrong value, pin it in `deploy.yml`:
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
- uses: daemux/daemux-plugins/.github/actions/ios-native-testflight@main
|
|
64
|
+
with:
|
|
65
|
+
project: MyApp.xcodeproj # if multiple .xcodeproj at root
|
|
66
|
+
workspace: MyApp.xcworkspace # wins over project
|
|
67
|
+
scheme: MyApp # if multiple application schemes
|
|
68
|
+
configuration: Release # default: Release
|
|
69
|
+
bundle-id: com.example.myapp # if PRODUCT_BUNDLE_IDENTIFIER is wrong
|
|
70
|
+
team-id: ABCDE12345 # if your ASC key is multi-team
|
|
71
|
+
app-store-apple-id: '1234567890' # to skip the ASC API lookup
|
|
72
|
+
app-store-whats-new: |
|
|
73
|
+
- New feature X
|
|
74
|
+
- Bug fixes
|
|
75
|
+
app-store-locale: en-US
|
|
76
|
+
uses-non-exempt-encryption: 'false'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Every input is optional. Omitted ones are auto-detected.
|
|
80
|
+
|
|
60
81
|
## Troubleshooting
|
|
61
82
|
|
|
62
83
|
| Error | Likely Cause | Fix |
|
|
63
84
|
|-------|--------------|-----|
|
|
64
85
|
| `No ASC key found in creds/` | File missing or misnamed | Filename must match `AuthKey_<KEY_ID>_Issuer_<ISSUER_UUID>.p8` exactly |
|
|
65
|
-
| `
|
|
86
|
+
| `Multiple ASC keys found in creds/` | More than one .p8 | Remove the unused one(s) — only a single key is supported |
|
|
87
|
+
| `No ASC app found for bundle <id>` | App not yet registered in ASC | Run Step 3 (create the app record) |
|
|
66
88
|
| `MARKETING_VERSION not set` | Missing in `.pbxproj` | Set `MARKETING_VERSION = 1.0;` in your target's build settings |
|
|
67
89
|
| Apple refuses new version | Prior version not in `READY_FOR_SALE` | Let the existing version finish review, or manually bump `MARKETING_VERSION` in Xcode |
|
|
68
|
-
| `Scheme not found` | Scheme not shared | In Xcode: Product → Scheme → Manage Schemes → tick "Shared", commit `*.xcscheme` |
|
|
90
|
+
| `Scheme not found` | Scheme not shared, or auto-detect picked wrong one | In Xcode: Product → Scheme → Manage Schemes → tick "Shared", commit `*.xcscheme`. Or pass `scheme:` in the workflow `with:` block. |
|
|
69
91
|
|
|
70
92
|
## Credential rotation
|
|
71
93
|
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Xcode project / scheme / bundle_id auto-detection.
|
|
4
|
+
|
|
5
|
+
Ported from gowalk-step/fastlane_standalone.sh — keeps us in Python (our
|
|
6
|
+
ecosystem) while still shelling out to ``xcodebuild`` for the two queries
|
|
7
|
+
only it can reliably answer:
|
|
8
|
+
|
|
9
|
+
``xcodebuild -list -json`` -> enumerate schemes
|
|
10
|
+
``xcodebuild -showBuildSettings -json`` -> PRODUCT_TYPE + bundle id
|
|
11
|
+
|
|
12
|
+
The detection lets ``ci.config.yaml`` become entirely optional: with just
|
|
13
|
+
``creds/AuthKey_*.p8`` + the 18-line ``deploy.yml`` the pipeline can still
|
|
14
|
+
figure out what to build.
|
|
15
|
+
|
|
16
|
+
Rules (kept intentionally boring — if auto-detect is ambiguous we log a
|
|
17
|
+
warning and return a deterministic choice, falling back to a clear
|
|
18
|
+
``::error::`` only when truly nothing works):
|
|
19
|
+
|
|
20
|
+
1. ``auto_detect_project(workspace)``
|
|
21
|
+
- Prefer a single ``*.xcworkspace`` at the repo root.
|
|
22
|
+
- Else a single ``*.xcodeproj``.
|
|
23
|
+
- When multiple ``.xcodeproj`` exist, prefer one matching the repo
|
|
24
|
+
basename, else alphabetically first (with a warning).
|
|
25
|
+
|
|
26
|
+
2. ``auto_detect_scheme(workspace, project, workspace_file)``
|
|
27
|
+
- ``xcodebuild -list -json`` to enumerate schemes.
|
|
28
|
+
- For each scheme, ``-showBuildSettings -json`` and keep those whose
|
|
29
|
+
``PRODUCT_TYPE == com.apple.product-type.application``.
|
|
30
|
+
- Single application scheme -> that one. Multiple: prefer repo-basename
|
|
31
|
+
match, else alphabetical first.
|
|
32
|
+
|
|
33
|
+
3. ``auto_detect_bundle_id(workspace, project, workspace_file, scheme, configuration)``
|
|
34
|
+
- Read ``PRODUCT_BUNDLE_IDENTIFIER`` from the same ``-showBuildSettings``
|
|
35
|
+
invocation (cached from step 2 when possible).
|
|
36
|
+
- Reject unresolved variable references like ``$(PRODUCT_NAME)``.
|
|
37
|
+
|
|
38
|
+
All xcodebuild invocations are cached per-process so repeated calls in the
|
|
39
|
+
same ``read_config.py`` run don't re-shell.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
from __future__ import annotations
|
|
43
|
+
|
|
44
|
+
import json
|
|
45
|
+
import subprocess
|
|
46
|
+
from pathlib import Path
|
|
47
|
+
from typing import Optional
|
|
48
|
+
|
|
49
|
+
from cfg_io import log, notice
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
APP_PRODUCT_TYPE = "com.apple.product-type.application"
|
|
53
|
+
# Timeouts (seconds) — xcodebuild can hang on missing toolchains or
|
|
54
|
+
# package resolution. CI should fail fast rather than spin forever.
|
|
55
|
+
LIST_TIMEOUT = 60
|
|
56
|
+
SETTINGS_TIMEOUT = 120
|
|
57
|
+
|
|
58
|
+
# Process-local caches keyed by (project, workspace_file) or
|
|
59
|
+
# (project, workspace_file, scheme, configuration). Cleared between test
|
|
60
|
+
# cases via ``_clear_caches`` but otherwise persist for the lifetime of
|
|
61
|
+
# the read_config.py process.
|
|
62
|
+
_list_cache: dict[tuple, Optional[list[str]]] = {}
|
|
63
|
+
_settings_cache: dict[tuple, Optional[dict]] = {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _clear_caches() -> None:
|
|
67
|
+
"""Reset caches — used by tests. Not part of the public API."""
|
|
68
|
+
_list_cache.clear()
|
|
69
|
+
_settings_cache.clear()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def auto_detect_project(workspace: Path) -> tuple[str, str]:
|
|
73
|
+
"""Discover the repo-root Xcode project / workspace.
|
|
74
|
+
|
|
75
|
+
Returns ``(project, workspace_file)`` where exactly one is a non-empty
|
|
76
|
+
filename. ``("", "")`` means nothing was found.
|
|
77
|
+
"""
|
|
78
|
+
workspaces = sorted(workspace.glob("*.xcworkspace"))
|
|
79
|
+
if workspaces:
|
|
80
|
+
picked = _pick_by_basename(workspaces, workspace, "xcworkspace")
|
|
81
|
+
log(f"auto-detect: workspace={picked.name}")
|
|
82
|
+
return "", picked.name
|
|
83
|
+
|
|
84
|
+
projects = sorted(workspace.glob("*.xcodeproj"))
|
|
85
|
+
if not projects:
|
|
86
|
+
return "", ""
|
|
87
|
+
picked = _pick_by_basename(projects, workspace, "xcodeproj")
|
|
88
|
+
log(f"auto-detect: project={picked.name}")
|
|
89
|
+
return picked.name, ""
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _pick_by_basename(matches: list[Path], workspace: Path, label: str) -> Path:
|
|
93
|
+
"""Pick the match whose name stem equals the repo basename, else first."""
|
|
94
|
+
if len(matches) == 1:
|
|
95
|
+
return matches[0]
|
|
96
|
+
repo_base = workspace.resolve().name.lower()
|
|
97
|
+
for match in matches:
|
|
98
|
+
if match.stem.lower() == repo_base:
|
|
99
|
+
return match
|
|
100
|
+
notice(
|
|
101
|
+
f"multiple *.{label} found; picking {matches[0].name} alphabetically. "
|
|
102
|
+
f"Set xcode.project in ci.config.yaml to disambiguate."
|
|
103
|
+
)
|
|
104
|
+
return matches[0]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _list_schemes(
|
|
108
|
+
workspace: Path, project: str, workspace_file: str
|
|
109
|
+
) -> Optional[list[str]]:
|
|
110
|
+
"""Run ``xcodebuild -list -json`` and return the schemes list (cached)."""
|
|
111
|
+
key = (project, workspace_file)
|
|
112
|
+
if key in _list_cache:
|
|
113
|
+
return _list_cache[key]
|
|
114
|
+
|
|
115
|
+
cmd = ["xcodebuild", "-list", "-json"]
|
|
116
|
+
if workspace_file:
|
|
117
|
+
cmd += ["-workspace", workspace_file]
|
|
118
|
+
elif project:
|
|
119
|
+
cmd += ["-project", project]
|
|
120
|
+
else:
|
|
121
|
+
_list_cache[key] = None
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
result = subprocess.run(
|
|
126
|
+
cmd, cwd=str(workspace), capture_output=True, text=True,
|
|
127
|
+
timeout=LIST_TIMEOUT,
|
|
128
|
+
)
|
|
129
|
+
except (OSError, subprocess.TimeoutExpired) as exc:
|
|
130
|
+
log(f"auto-detect: xcodebuild -list failed: {exc!r}")
|
|
131
|
+
_list_cache[key] = None
|
|
132
|
+
return None
|
|
133
|
+
|
|
134
|
+
if result.returncode != 0:
|
|
135
|
+
log(
|
|
136
|
+
f"auto-detect: xcodebuild -list returned {result.returncode}: "
|
|
137
|
+
f"{result.stderr.strip()}"
|
|
138
|
+
)
|
|
139
|
+
_list_cache[key] = None
|
|
140
|
+
return None
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
data = json.loads(result.stdout)
|
|
144
|
+
except json.JSONDecodeError as exc:
|
|
145
|
+
log(f"auto-detect: xcodebuild -list produced invalid JSON: {exc!r}")
|
|
146
|
+
_list_cache[key] = None
|
|
147
|
+
return None
|
|
148
|
+
|
|
149
|
+
# Workspace output has {"workspace": {"schemes": [...]}}; project has
|
|
150
|
+
# {"project": {"schemes": [...]}}.
|
|
151
|
+
container = data.get("workspace") or data.get("project") or {}
|
|
152
|
+
schemes = container.get("schemes") or []
|
|
153
|
+
_list_cache[key] = list(schemes)
|
|
154
|
+
return _list_cache[key]
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _show_build_settings(
|
|
158
|
+
workspace: Path,
|
|
159
|
+
project: str,
|
|
160
|
+
workspace_file: str,
|
|
161
|
+
scheme: str,
|
|
162
|
+
configuration: str,
|
|
163
|
+
) -> Optional[dict]:
|
|
164
|
+
"""Run ``xcodebuild -showBuildSettings -json`` and return buildSettings (cached)."""
|
|
165
|
+
key = (project, workspace_file, scheme, configuration or "Release")
|
|
166
|
+
if key in _settings_cache:
|
|
167
|
+
return _settings_cache[key]
|
|
168
|
+
|
|
169
|
+
cmd = ["xcodebuild", "-showBuildSettings", "-json", "-scheme", scheme]
|
|
170
|
+
if configuration:
|
|
171
|
+
cmd += ["-configuration", configuration]
|
|
172
|
+
if workspace_file:
|
|
173
|
+
cmd += ["-workspace", workspace_file]
|
|
174
|
+
elif project:
|
|
175
|
+
cmd += ["-project", project]
|
|
176
|
+
else:
|
|
177
|
+
_settings_cache[key] = None
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
result = subprocess.run(
|
|
182
|
+
cmd, cwd=str(workspace), capture_output=True, text=True,
|
|
183
|
+
timeout=SETTINGS_TIMEOUT,
|
|
184
|
+
)
|
|
185
|
+
except (OSError, subprocess.TimeoutExpired) as exc:
|
|
186
|
+
log(f"auto-detect: showBuildSettings({scheme!r}) failed: {exc!r}")
|
|
187
|
+
_settings_cache[key] = None
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
if result.returncode != 0:
|
|
191
|
+
log(
|
|
192
|
+
f"auto-detect: showBuildSettings({scheme!r}) returned "
|
|
193
|
+
f"{result.returncode}: {result.stderr.strip()}"
|
|
194
|
+
)
|
|
195
|
+
_settings_cache[key] = None
|
|
196
|
+
return None
|
|
197
|
+
|
|
198
|
+
try:
|
|
199
|
+
data = json.loads(result.stdout)
|
|
200
|
+
except json.JSONDecodeError as exc:
|
|
201
|
+
log(f"auto-detect: showBuildSettings({scheme!r}) invalid JSON: {exc!r}")
|
|
202
|
+
_settings_cache[key] = None
|
|
203
|
+
return None
|
|
204
|
+
|
|
205
|
+
if not isinstance(data, list) or not data:
|
|
206
|
+
_settings_cache[key] = None
|
|
207
|
+
return None
|
|
208
|
+
settings = data[0].get("buildSettings") or {}
|
|
209
|
+
_settings_cache[key] = settings if isinstance(settings, dict) else None
|
|
210
|
+
return _settings_cache[key]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def auto_detect_scheme(
|
|
214
|
+
workspace: Path, project: str, workspace_file: str
|
|
215
|
+
) -> Optional[str]:
|
|
216
|
+
"""Pick the single ``com.apple.product-type.application`` scheme."""
|
|
217
|
+
schemes = _list_schemes(workspace, project, workspace_file)
|
|
218
|
+
if not schemes:
|
|
219
|
+
return None
|
|
220
|
+
|
|
221
|
+
app_schemes: list[str] = []
|
|
222
|
+
for scheme in schemes:
|
|
223
|
+
settings = _show_build_settings(
|
|
224
|
+
workspace, project, workspace_file, scheme, "Release",
|
|
225
|
+
)
|
|
226
|
+
if not settings:
|
|
227
|
+
continue
|
|
228
|
+
if settings.get("PRODUCT_TYPE") == APP_PRODUCT_TYPE:
|
|
229
|
+
app_schemes.append(scheme)
|
|
230
|
+
|
|
231
|
+
if not app_schemes:
|
|
232
|
+
return None
|
|
233
|
+
if len(app_schemes) == 1:
|
|
234
|
+
log(f"auto-detect: scheme={app_schemes[0]}")
|
|
235
|
+
return app_schemes[0]
|
|
236
|
+
|
|
237
|
+
repo_base = workspace.resolve().name.lower()
|
|
238
|
+
for scheme in app_schemes:
|
|
239
|
+
if scheme.lower() == repo_base:
|
|
240
|
+
log(f"auto-detect: scheme={scheme} (basename match)")
|
|
241
|
+
return scheme
|
|
242
|
+
|
|
243
|
+
picked = sorted(app_schemes)[0]
|
|
244
|
+
notice(
|
|
245
|
+
f"multiple application schemes found ({', '.join(sorted(app_schemes))}); "
|
|
246
|
+
f"picking {picked} alphabetically. Set xcode.scheme in ci.config.yaml "
|
|
247
|
+
f"to disambiguate."
|
|
248
|
+
)
|
|
249
|
+
return picked
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def auto_detect_bundle_id(
|
|
253
|
+
workspace: Path,
|
|
254
|
+
project: str,
|
|
255
|
+
workspace_file: str,
|
|
256
|
+
scheme: str,
|
|
257
|
+
configuration: str,
|
|
258
|
+
) -> Optional[str]:
|
|
259
|
+
"""Extract ``PRODUCT_BUNDLE_IDENTIFIER`` for the given scheme/config."""
|
|
260
|
+
settings = _show_build_settings(
|
|
261
|
+
workspace, project, workspace_file, scheme, configuration or "Release",
|
|
262
|
+
)
|
|
263
|
+
if not settings:
|
|
264
|
+
return None
|
|
265
|
+
bundle = settings.get("PRODUCT_BUNDLE_IDENTIFIER")
|
|
266
|
+
if not bundle or not isinstance(bundle, str):
|
|
267
|
+
return None
|
|
268
|
+
# xcodebuild sometimes emits unresolved variable references when build
|
|
269
|
+
# settings depend on xcconfig files that aren't in the default context.
|
|
270
|
+
if "$(" in bundle or bundle.startswith("$") or "=" in bundle:
|
|
271
|
+
log(f"auto-detect: bundle_id {bundle!r} contains unresolved variable — rejecting")
|
|
272
|
+
return None
|
|
273
|
+
log(f"auto-detect: bundle_id={bundle}")
|
|
274
|
+
return bundle
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
|
|
3
|
+
Shared helpers for ios-native-testflight read_config.py.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Now that ci.config.yaml is gone, this module only contains the helpers
|
|
6
|
+
that interact with the filesystem or App Store Connect — no YAML or
|
|
7
|
+
config-precedence logic remains.
|
|
7
8
|
|
|
8
9
|
Contents:
|
|
9
|
-
load_config YAML loader (returns {} if missing)
|
|
10
10
|
emit $GITHUB_ENV writer (handles multi-line via heredoc)
|
|
11
|
-
dig / pick Safe nested dict access
|
|
12
|
-
pick_with_source Flat-path-first, legacy-alias-second lookup
|
|
13
|
-
resolve Apply input -> config -> auto -> default precedence
|
|
14
|
-
auto_project_glob Repo-root *.xcodeproj / *.xcworkspace autodetect
|
|
15
|
-
as_str_bool YAML bool -> "true"/"false"/None
|
|
16
11
|
find_p8 Locate ASC .p8 key in creds/
|
|
12
|
+
derive_team_if_empty ASC API fallback for team_id
|
|
17
13
|
lookup_app_id_via_api Subprocess helper — calls lookup_app_id.py
|
|
18
14
|
"""
|
|
19
15
|
|
|
@@ -21,14 +17,12 @@ from __future__ import annotations
|
|
|
21
17
|
|
|
22
18
|
import os
|
|
23
19
|
import re
|
|
20
|
+
import subprocess
|
|
24
21
|
import sys
|
|
25
22
|
from pathlib import Path
|
|
26
|
-
from typing import Any
|
|
27
|
-
|
|
28
|
-
import yaml
|
|
29
23
|
|
|
30
24
|
from asc_common import make_jwt
|
|
31
|
-
from cfg_io import fail, log
|
|
25
|
+
from cfg_io import fail, log
|
|
32
26
|
from team_resolver import derive_team_id
|
|
33
27
|
|
|
34
28
|
|
|
@@ -37,27 +31,6 @@ P8_RE = re.compile(
|
|
|
37
31
|
)
|
|
38
32
|
|
|
39
33
|
|
|
40
|
-
def load_config(workspace: Path, rel_path: str) -> dict:
|
|
41
|
-
"""Load a YAML config from ``workspace/rel_path``. Returns {} if missing."""
|
|
42
|
-
cfg_path = workspace / rel_path
|
|
43
|
-
if not cfg_path.is_file():
|
|
44
|
-
notice(
|
|
45
|
-
f"{rel_path} not found at {cfg_path}; proceeding with inputs and defaults only"
|
|
46
|
-
)
|
|
47
|
-
return {}
|
|
48
|
-
try:
|
|
49
|
-
with cfg_path.open("r") as fh:
|
|
50
|
-
data = yaml.safe_load(fh)
|
|
51
|
-
except yaml.YAMLError as exc:
|
|
52
|
-
fail(f"failed to parse {rel_path}: {exc}")
|
|
53
|
-
if data is None:
|
|
54
|
-
return {}
|
|
55
|
-
if not isinstance(data, dict):
|
|
56
|
-
fail(f"{rel_path} root must be a mapping")
|
|
57
|
-
log(f"loaded config from {cfg_path}")
|
|
58
|
-
return data
|
|
59
|
-
|
|
60
|
-
|
|
61
34
|
def emit(env_file: Path, name: str, value: str) -> None:
|
|
62
35
|
"""Append NAME=VALUE (or multi-line NAME<<EOF ... EOF) to $GITHUB_ENV."""
|
|
63
36
|
if value is None:
|
|
@@ -73,82 +46,12 @@ def emit(env_file: Path, name: str, value: str) -> None:
|
|
|
73
46
|
fh.write(f"{name}={value}\n")
|
|
74
47
|
|
|
75
48
|
|
|
76
|
-
def
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
node = node.get(key)
|
|
83
|
-
if node is None:
|
|
84
|
-
return default
|
|
85
|
-
return node
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def pick(cfg: dict, *paths: tuple) -> Any:
|
|
89
|
-
"""Return the first non-None/non-empty value among a series of paths."""
|
|
90
|
-
for path in paths:
|
|
91
|
-
val = dig(cfg, *path)
|
|
92
|
-
if val not in (None, ""):
|
|
93
|
-
return val
|
|
94
|
-
return None
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def pick_with_source(cfg: dict, flat: tuple, legacy: tuple) -> tuple[Any, str]:
|
|
98
|
-
"""Return (value, source) — flat path wins; legacy alias as fallback."""
|
|
99
|
-
flat_val = dig(cfg, *flat)
|
|
100
|
-
if flat_val not in (None, ""):
|
|
101
|
-
return flat_val, "config"
|
|
102
|
-
legacy_val = dig(cfg, *legacy)
|
|
103
|
-
if legacy_val not in (None, ""):
|
|
104
|
-
return legacy_val, "config(legacy)"
|
|
105
|
-
return None, "config"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def resolve(
|
|
109
|
-
input_val: str,
|
|
110
|
-
cfg_val: Any,
|
|
111
|
-
*,
|
|
112
|
-
cfg_source: str = "config",
|
|
113
|
-
auto_val: str = "",
|
|
114
|
-
default: str = "",
|
|
115
|
-
) -> tuple[str, str]:
|
|
116
|
-
"""Apply precedence: input > config > auto > default > empty."""
|
|
117
|
-
if input_val:
|
|
118
|
-
return input_val, "input"
|
|
119
|
-
if cfg_val not in (None, ""):
|
|
120
|
-
return str(cfg_val), cfg_source
|
|
121
|
-
if auto_val:
|
|
122
|
-
return auto_val, "auto-detect"
|
|
123
|
-
if default:
|
|
124
|
-
return default, "default"
|
|
125
|
-
return "", "empty"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def auto_project_glob(workspace: Path, suffix: str) -> str:
|
|
129
|
-
"""Return the single matching *suffix file at repo root, else empty."""
|
|
130
|
-
matches = sorted(workspace.glob(f"*{suffix}"))
|
|
131
|
-
if len(matches) == 1:
|
|
132
|
-
return matches[0].name
|
|
133
|
-
return ""
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def as_str_bool(val: Any) -> str | None:
|
|
137
|
-
"""Normalize YAML bool / string / None to 'true'|'false'|None."""
|
|
138
|
-
if val is None:
|
|
139
|
-
return None
|
|
140
|
-
if isinstance(val, bool):
|
|
141
|
-
return "true" if val else "false"
|
|
142
|
-
s = str(val).strip().lower()
|
|
143
|
-
if s in ("true", "yes", "1"):
|
|
144
|
-
return "true"
|
|
145
|
-
if s in ("false", "no", "0"):
|
|
146
|
-
return "false"
|
|
147
|
-
return s # let downstream validate
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def find_p8(workspace: Path, cfg: dict) -> tuple[Path, str, str | None]:
|
|
151
|
-
"""Locate the ASC .p8 key. Returns (path, key_id, issuer_from_filename)."""
|
|
49
|
+
def find_p8(workspace: Path) -> tuple[Path, str, str | None]:
|
|
50
|
+
"""Locate the ASC .p8 key. Returns (path, key_id, issuer_from_filename).
|
|
51
|
+
|
|
52
|
+
If multiple keys are found we fail with an actionable message — there is
|
|
53
|
+
no longer a config-based disambiguation channel.
|
|
54
|
+
"""
|
|
152
55
|
creds_dir = workspace / "creds"
|
|
153
56
|
matches = sorted(creds_dir.glob("AuthKey_*.p8"))
|
|
154
57
|
if not matches:
|
|
@@ -170,23 +73,13 @@ def find_p8(workspace: Path, cfg: dict) -> tuple[Path, str, str | None]:
|
|
|
170
73
|
"Found .p8 file(s) in creds/ but none match the required naming "
|
|
171
74
|
"pattern AuthKey_<KEY_ID>[_Issuer_<UUID>].p8"
|
|
172
75
|
)
|
|
173
|
-
|
|
174
76
|
if len(parsed) == 1:
|
|
175
77
|
return parsed[0]
|
|
176
78
|
|
|
177
|
-
|
|
178
|
-
if not config_key_id:
|
|
179
|
-
names = ", ".join(p.name for p, _, _ in parsed)
|
|
180
|
-
fail(
|
|
181
|
-
f"Multiple ASC keys found in creds/ ({names}). "
|
|
182
|
-
"Set credentials.apple.key_id in ci.config.yaml to choose one."
|
|
183
|
-
)
|
|
184
|
-
for entry in parsed:
|
|
185
|
-
if entry[1] == config_key_id:
|
|
186
|
-
return entry
|
|
79
|
+
names = ", ".join(p.name for p, _, _ in parsed)
|
|
187
80
|
fail(
|
|
188
|
-
f"
|
|
189
|
-
|
|
81
|
+
f"Multiple ASC keys found in creds/ ({names}). Remove the unused "
|
|
82
|
+
"ones — only a single key is supported."
|
|
190
83
|
)
|
|
191
84
|
|
|
192
85
|
|
|
@@ -217,8 +110,6 @@ def derive_team_if_empty(
|
|
|
217
110
|
|
|
218
111
|
def lookup_app_id_via_api(bundle_id: str, scripts_dir: Path) -> str:
|
|
219
112
|
"""Invoke lookup_app_id.py to resolve apple_id via ASC API."""
|
|
220
|
-
import subprocess
|
|
221
|
-
|
|
222
113
|
script = scripts_dir / "lookup_app_id.py"
|
|
223
114
|
if not script.is_file():
|
|
224
115
|
fail(f"lookup_app_id.py not found at {script}")
|
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
|
|
4
|
-
environment variables to $GITHUB_ENV.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ci.{run_tests, test_command, test_destination}
|
|
12
|
-
credentials.apple.{key_id, issuer_id} OR asc.{key_id, issuer_id}
|
|
13
|
-
|
|
14
|
-
Legacy aliases (accepted for back-compat, never preferred):
|
|
15
|
-
ios.native.{project, workspace, scheme, configuration, profile_name,
|
|
16
|
-
team_id, app_store_apple_id, uses_non_exempt_encryption,
|
|
17
|
-
whats_new, locale, run_tests, test_command, test_destination,
|
|
18
|
-
tests.{run, command, destination}}
|
|
19
|
-
app_store.locale (third-tier fallback only)
|
|
3
|
+
Discover ASC API key in creds/ + auto-detect Xcode project/scheme/bundle,
|
|
4
|
+
then emit derived CI environment variables to $GITHUB_ENV.
|
|
5
|
+
|
|
6
|
+
There is NO config file. This script reads only:
|
|
7
|
+
- INPUT_* env vars (the composite action's `with:` overrides)
|
|
8
|
+
- creds/AuthKey_<KEY_ID>_Issuer_<UUID>.p8 (the only required file)
|
|
9
|
+
- the Xcode project (via auto_detect.py + xcodebuild)
|
|
10
|
+
- the App Store Connect API (for team_id and app_store_apple_id)
|
|
20
11
|
|
|
21
12
|
Precedence for every CFG_* value:
|
|
22
|
-
1.
|
|
23
|
-
2.
|
|
24
|
-
3.
|
|
25
|
-
4.
|
|
26
|
-
5. Empty string (composite action step applies its own default / skips)
|
|
13
|
+
1. INPUT_* env var (composite action input)
|
|
14
|
+
2. Auto-detected value (xcodebuild, ASC API, glob)
|
|
15
|
+
3. Built-in default ("Release", "false", "en-US", whatsNew boilerplate)
|
|
16
|
+
4. Empty string (downstream step skips or applies its own fallback)
|
|
27
17
|
|
|
28
|
-
Built-in defaults
|
|
18
|
+
Built-in defaults emitted when nothing else applies:
|
|
29
19
|
CFG_CONFIGURATION=Release, CFG_USES_NON_EXEMPT=false,
|
|
30
|
-
CFG_RUN_TESTS=false, CFG_LOCALE=en-US,
|
|
31
|
-
|
|
20
|
+
CFG_RUN_TESTS=false, CFG_LOCALE=en-US,
|
|
21
|
+
CFG_PROFILE_NAME="<scheme> CI", CFG_WHATS_NEW=<boilerplate>.
|
|
32
22
|
|
|
33
23
|
The ASC .p8 key is located by globbing ``creds/AuthKey_*.p8`` with filename
|
|
34
|
-
regex AuthKey_<KEY_ID>[_Issuer_<ISSUER_UUID>].p8.
|
|
35
|
-
|
|
24
|
+
regex AuthKey_<KEY_ID>[_Issuer_<ISSUER_UUID>].p8. If multiple match, we fail
|
|
25
|
+
with an instruction to remove the unwanted one(s) — there is no longer a
|
|
26
|
+
config-based disambiguation channel.
|
|
36
27
|
|
|
37
28
|
Writes to $GITHUB_ENV:
|
|
38
29
|
ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_P8_PATH, ASC_KEY_P8,
|
|
@@ -53,19 +44,13 @@ from __future__ import annotations
|
|
|
53
44
|
import os
|
|
54
45
|
from pathlib import Path
|
|
55
46
|
|
|
47
|
+
import auto_detect
|
|
56
48
|
from cfg_io import fail, log
|
|
57
49
|
from cfg_resolve import (
|
|
58
|
-
as_str_bool,
|
|
59
|
-
auto_project_glob,
|
|
60
50
|
derive_team_if_empty,
|
|
61
|
-
dig,
|
|
62
51
|
emit,
|
|
63
52
|
find_p8,
|
|
64
|
-
load_config,
|
|
65
53
|
lookup_app_id_via_api,
|
|
66
|
-
pick,
|
|
67
|
-
pick_with_source,
|
|
68
|
-
resolve,
|
|
69
54
|
)
|
|
70
55
|
|
|
71
56
|
|
|
@@ -76,65 +61,83 @@ DEFAULT_WHATS_NEW = (
|
|
|
76
61
|
)
|
|
77
62
|
|
|
78
63
|
|
|
79
|
-
def
|
|
64
|
+
def _pick(input_val: str, *, auto_val: str = "", default: str = "") -> tuple[str, str]:
|
|
65
|
+
"""Apply precedence: input > auto > default > empty."""
|
|
66
|
+
if input_val:
|
|
67
|
+
return input_val, "input"
|
|
68
|
+
if auto_val:
|
|
69
|
+
return auto_val, "auto-detect"
|
|
70
|
+
if default:
|
|
71
|
+
return default, "default"
|
|
72
|
+
return "", "empty"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def emit_credentials(env_file: Path, workspace: Path) -> dict:
|
|
80
76
|
"""Discover .p8, derive ASC_KEY_ID / ISSUER / PATH, emit to env_file.
|
|
81
77
|
|
|
82
78
|
Returns {'key_id', 'issuer_id', 'key_path'} for downstream use.
|
|
83
79
|
"""
|
|
84
|
-
p8_path, key_id_from_file, issuer_from_file = find_p8(workspace
|
|
80
|
+
p8_path, key_id_from_file, issuer_from_file = find_p8(workspace)
|
|
85
81
|
try:
|
|
86
82
|
p8_contents = p8_path.read_text()
|
|
87
83
|
except OSError as exc:
|
|
88
84
|
fail(f"cannot read {p8_path}: {exc}")
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
cfg_issuer = pick(cfg, ("credentials", "apple", "issuer_id"), ("asc", "issuer_id"))
|
|
92
|
-
asc_key_id = cfg_key_id or key_id_from_file
|
|
93
|
-
asc_issuer = cfg_issuer or issuer_from_file
|
|
94
|
-
if not asc_issuer:
|
|
86
|
+
if not issuer_from_file:
|
|
95
87
|
fail(
|
|
96
|
-
"ASC issuer id unknown:
|
|
97
|
-
"
|
|
88
|
+
"ASC issuer id unknown: rename the .p8 to "
|
|
89
|
+
"AuthKey_<KEY_ID>_Issuer_<UUID>.p8 so the issuer id is in the filename."
|
|
98
90
|
)
|
|
99
91
|
|
|
100
|
-
emit(env_file, "ASC_KEY_ID", str(
|
|
101
|
-
emit(env_file, "ASC_ISSUER_ID", str(
|
|
92
|
+
emit(env_file, "ASC_KEY_ID", str(key_id_from_file))
|
|
93
|
+
emit(env_file, "ASC_ISSUER_ID", str(issuer_from_file))
|
|
102
94
|
emit(env_file, "ASC_KEY_P8_PATH", str(p8_path))
|
|
103
95
|
emit(env_file, "ASC_KEY_P8", p8_contents)
|
|
104
|
-
log(f"ASC_KEY_ID={
|
|
105
|
-
log(f"ASC_ISSUER_ID={
|
|
96
|
+
log(f"ASC_KEY_ID={key_id_from_file} (source: filename)")
|
|
97
|
+
log(f"ASC_ISSUER_ID={issuer_from_file} (source: filename)")
|
|
106
98
|
log(f"ASC_KEY_P8_PATH={p8_path}")
|
|
107
|
-
return {
|
|
99
|
+
return {
|
|
100
|
+
"key_id": str(key_id_from_file),
|
|
101
|
+
"issuer_id": str(issuer_from_file),
|
|
102
|
+
"key_path": str(p8_path),
|
|
103
|
+
}
|
|
108
104
|
|
|
109
105
|
|
|
110
|
-
def
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
def _detect_project_workspace(
|
|
107
|
+
workspace: Path,
|
|
108
|
+
project: tuple[str, str],
|
|
109
|
+
ws_val: tuple[str, str],
|
|
110
|
+
) -> tuple[tuple[str, str], tuple[str, str]]:
|
|
111
|
+
"""Run auto_detect.auto_detect_project when both are unset."""
|
|
112
|
+
if project[0] or ws_val[0]:
|
|
113
|
+
return project, ws_val
|
|
114
|
+
auto_proj, auto_ws = auto_detect.auto_detect_project(workspace)
|
|
115
|
+
if auto_ws:
|
|
116
|
+
return project, (auto_ws, "auto-detect")
|
|
117
|
+
if auto_proj:
|
|
118
|
+
return (auto_proj, "auto-detect"), ws_val
|
|
119
|
+
return project, ws_val
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def resolve_xcode(workspace: Path, inp: dict) -> dict:
|
|
123
|
+
"""Resolve project / workspace / scheme / configuration / profile_name.
|
|
124
|
+
|
|
125
|
+
Inputs win; otherwise we shell out to xcodebuild via auto_detect.
|
|
126
|
+
"""
|
|
127
|
+
project = _pick(inp["PROJECT"])
|
|
128
|
+
ws_val = _pick(inp["WORKSPACE"])
|
|
129
|
+
project, ws_val = _detect_project_workspace(workspace, project, ws_val)
|
|
130
|
+
|
|
131
|
+
configuration = _pick(inp["CONFIGURATION"], default="Release")
|
|
132
|
+
|
|
133
|
+
scheme = _pick(inp["SCHEME"])
|
|
134
|
+
if not scheme[0] and (project[0] or ws_val[0]):
|
|
135
|
+
detected = auto_detect.auto_detect_scheme(workspace, project[0], ws_val[0])
|
|
136
|
+
if detected:
|
|
137
|
+
scheme = (detected, "auto-detect")
|
|
121
138
|
|
|
122
|
-
project = resolve(
|
|
123
|
-
inp["PROJECT"], proj_cfg, cfg_source=proj_src,
|
|
124
|
-
auto_val=auto_project_glob(workspace, ".xcodeproj"),
|
|
125
|
-
)
|
|
126
|
-
ws_val = resolve(
|
|
127
|
-
inp["WORKSPACE"], ws_cfg, cfg_source=ws_src,
|
|
128
|
-
auto_val=auto_project_glob(workspace, ".xcworkspace"),
|
|
129
|
-
)
|
|
130
|
-
scheme = resolve(inp["SCHEME"], scheme_cfg, cfg_source=scheme_src)
|
|
131
|
-
configuration = resolve(
|
|
132
|
-
inp["CONFIGURATION"], config_cfg, cfg_source=config_src, default="Release",
|
|
133
|
-
)
|
|
134
139
|
default_profile = f"{scheme[0]} CI" if scheme[0] else ""
|
|
135
|
-
profile_name =
|
|
136
|
-
inp["PROFILE_NAME"], profile_cfg, cfg_source=profile_src, default=default_profile,
|
|
137
|
-
)
|
|
140
|
+
profile_name = _pick(inp["PROFILE_NAME"], default=default_profile)
|
|
138
141
|
return {
|
|
139
142
|
"project": project,
|
|
140
143
|
"workspace": ws_val,
|
|
@@ -144,113 +147,81 @@ def resolve_xcode(cfg: dict, workspace: Path, inp: dict) -> dict:
|
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
|
|
147
|
-
def
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
def _detect_bundle(
|
|
151
|
+
bundle: tuple[str, str], workspace: Path, xcode: dict,
|
|
152
|
+
) -> tuple[str, str]:
|
|
153
|
+
"""Auto-detect PRODUCT_BUNDLE_IDENTIFIER when bundle is unresolved."""
|
|
154
|
+
if bundle[0] or not xcode.get("scheme"):
|
|
155
|
+
return bundle
|
|
156
|
+
detected = auto_detect.auto_detect_bundle_id(
|
|
157
|
+
workspace,
|
|
158
|
+
xcode.get("project", ""),
|
|
159
|
+
xcode.get("workspace", ""),
|
|
160
|
+
xcode["scheme"],
|
|
161
|
+
xcode.get("configuration", "Release"),
|
|
153
162
|
)
|
|
163
|
+
if detected:
|
|
164
|
+
return detected, "auto-detect"
|
|
165
|
+
return bundle
|
|
154
166
|
|
|
155
|
-
bundle = resolve(inp["BUNDLE_ID"], bundle_cfg, cfg_source=bundle_src)
|
|
156
|
-
team = resolve(inp["TEAM_ID"], team_cfg, cfg_source=team_src)
|
|
157
167
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
def _resolve_apple_id(
|
|
169
|
+
inp: dict, bundle: tuple[str, str], creds: dict, scripts_dir: Path,
|
|
170
|
+
) -> tuple[str, str]:
|
|
171
|
+
"""Resolve App Store numeric app id: input -> ASC API lookup -> empty."""
|
|
172
|
+
if inp["APP_STORE_APPLE_ID"]:
|
|
173
|
+
return inp["APP_STORE_APPLE_ID"], "input"
|
|
174
|
+
if not bundle[0]:
|
|
175
|
+
return "", "empty"
|
|
176
|
+
os.environ["ASC_KEY_ID"] = creds["key_id"]
|
|
177
|
+
os.environ["ASC_ISSUER_ID"] = creds["issuer_id"]
|
|
178
|
+
os.environ["ASC_KEY_PATH"] = creds["key_path"]
|
|
179
|
+
return lookup_app_id_via_api(bundle[0], scripts_dir), "api-lookup"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def resolve_app(
|
|
183
|
+
inp: dict,
|
|
184
|
+
creds: dict,
|
|
185
|
+
scripts_dir: Path,
|
|
186
|
+
*,
|
|
187
|
+
workspace: Path,
|
|
188
|
+
xcode: dict,
|
|
189
|
+
) -> dict:
|
|
190
|
+
"""Resolve bundle_id / team_id / app_store_apple_id."""
|
|
191
|
+
bundle = _pick(inp["BUNDLE_ID"])
|
|
192
|
+
bundle = _detect_bundle(bundle, workspace, xcode)
|
|
193
|
+
|
|
194
|
+
team = _pick(inp["TEAM_ID"])
|
|
161
195
|
if not team[0]:
|
|
162
196
|
derived_val, derived_src = derive_team_if_empty(team[0], team[1], creds)
|
|
163
197
|
if derived_val:
|
|
164
|
-
log(
|
|
165
|
-
f"derived team_id={derived_val} from ASC key "
|
|
166
|
-
f"{creds['key_id']}"
|
|
167
|
-
)
|
|
198
|
+
log(f"derived team_id={derived_val} from ASC key {creds['key_id']}")
|
|
168
199
|
team = (derived_val, derived_src)
|
|
169
200
|
|
|
170
|
-
|
|
171
|
-
apple = (inp["APP_STORE_APPLE_ID"], "input")
|
|
172
|
-
elif apple_cfg not in (None, ""):
|
|
173
|
-
apple = (str(apple_cfg), apple_src)
|
|
174
|
-
elif bundle[0]:
|
|
175
|
-
os.environ["ASC_KEY_ID"] = creds["key_id"]
|
|
176
|
-
os.environ["ASC_ISSUER_ID"] = creds["issuer_id"]
|
|
177
|
-
os.environ["ASC_KEY_PATH"] = creds["key_path"]
|
|
178
|
-
apple = (lookup_app_id_via_api(bundle[0], scripts_dir), "api-lookup")
|
|
179
|
-
else:
|
|
180
|
-
apple = ("", "empty")
|
|
201
|
+
apple = _resolve_apple_id(inp, bundle, creds, scripts_dir)
|
|
181
202
|
return {"bundle_id": bundle, "team_id": team, "app_store_apple_id": apple}
|
|
182
203
|
|
|
183
204
|
|
|
184
|
-
def resolve_testflight(
|
|
185
|
-
"""Resolve whats_new / locale from
|
|
186
|
-
whats_cfg, whats_src = pick_with_source(
|
|
187
|
-
cfg, ("testflight", "whats_new"), ("ios", "native", "whats_new"),
|
|
188
|
-
)
|
|
189
|
-
locale_cfg, locale_src = pick_with_source(
|
|
190
|
-
cfg, ("testflight", "locale"), ("ios", "native", "locale"),
|
|
191
|
-
)
|
|
192
|
-
if locale_cfg in (None, ""):
|
|
193
|
-
alt = dig(cfg, "app_store", "locale")
|
|
194
|
-
if alt not in (None, ""):
|
|
195
|
-
locale_cfg, locale_src = alt, "config(legacy)"
|
|
205
|
+
def resolve_testflight(inp: dict) -> dict:
|
|
206
|
+
"""Resolve whats_new / locale from inputs, with built-in defaults."""
|
|
196
207
|
return {
|
|
197
|
-
"whats_new":
|
|
198
|
-
|
|
199
|
-
),
|
|
200
|
-
"locale": resolve(inp["LOCALE"], locale_cfg, cfg_source=locale_src, default="en-US"),
|
|
208
|
+
"whats_new": _pick(inp["WHATS_NEW"], default=DEFAULT_WHATS_NEW),
|
|
209
|
+
"locale": _pick(inp["LOCALE"], default="en-US"),
|
|
201
210
|
}
|
|
202
211
|
|
|
203
212
|
|
|
204
|
-
def resolve_tests(
|
|
205
|
-
"""Resolve run_tests / test_command / test_destination from
|
|
206
|
-
run_flat = dig(cfg, "ci", "run_tests")
|
|
207
|
-
run_legacy = dig(cfg, "ios", "native", "run_tests")
|
|
208
|
-
if run_legacy is None:
|
|
209
|
-
run_legacy = dig(cfg, "ios", "native", "tests", "run")
|
|
210
|
-
run_cfg, run_src = (run_flat, "config") if run_flat is not None else (run_legacy, "config(legacy)")
|
|
211
|
-
|
|
212
|
-
cmd_flat = dig(cfg, "ci", "test_command")
|
|
213
|
-
cmd_legacy = dig(cfg, "ios", "native", "test_command") or dig(cfg, "ios", "native", "tests", "command")
|
|
214
|
-
cmd_cfg, cmd_src = (
|
|
215
|
-
(cmd_flat, "config") if cmd_flat not in (None, "") else (cmd_legacy, "config(legacy)")
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
dest_flat = dig(cfg, "ci", "test_destination")
|
|
219
|
-
dest_legacy = (
|
|
220
|
-
dig(cfg, "ios", "native", "test_destination")
|
|
221
|
-
or dig(cfg, "ios", "native", "tests", "destination")
|
|
222
|
-
)
|
|
223
|
-
dest_cfg, dest_src = (
|
|
224
|
-
(dest_flat, "config") if dest_flat not in (None, "") else (dest_legacy, "config(legacy)")
|
|
225
|
-
)
|
|
226
|
-
|
|
213
|
+
def resolve_tests(inp: dict) -> dict:
|
|
214
|
+
"""Resolve run_tests / test_command / test_destination from inputs."""
|
|
227
215
|
return {
|
|
228
|
-
"run_tests":
|
|
229
|
-
|
|
230
|
-
),
|
|
231
|
-
"test_command": resolve(inp["TEST_COMMAND"], cmd_cfg, cfg_source=cmd_src),
|
|
232
|
-
"test_destination": resolve(inp["TEST_DESTINATION"], dest_cfg, cfg_source=dest_src),
|
|
216
|
+
"run_tests": _pick(inp["RUN_TESTS"], default="false"),
|
|
217
|
+
"test_command": _pick(inp["TEST_COMMAND"]),
|
|
218
|
+
"test_destination": _pick(inp["TEST_DESTINATION"]),
|
|
233
219
|
}
|
|
234
220
|
|
|
235
221
|
|
|
236
|
-
def resolve_ios(
|
|
237
|
-
"""Resolve ios.uses_non_exempt_encryption
|
|
238
|
-
|
|
239
|
-
# Flat lookup can accidentally return the legacy 'native' sub-dict; ignore.
|
|
240
|
-
if isinstance(val_flat, dict):
|
|
241
|
-
val_flat = None
|
|
242
|
-
val_legacy = dig(cfg, "ios", "native", "uses_non_exempt_encryption")
|
|
243
|
-
if val_flat is not None:
|
|
244
|
-
raw, src = val_flat, "config"
|
|
245
|
-
elif val_legacy is not None:
|
|
246
|
-
raw, src = val_legacy, "config(legacy)"
|
|
247
|
-
else:
|
|
248
|
-
raw, src = None, "config"
|
|
249
|
-
return {
|
|
250
|
-
"uses_non_exempt": resolve(
|
|
251
|
-
inp["USES_NON_EXEMPT"], as_str_bool(raw), cfg_source=src, default="false",
|
|
252
|
-
)
|
|
253
|
-
}
|
|
222
|
+
def resolve_ios(inp: dict) -> dict:
|
|
223
|
+
"""Resolve ios.uses_non_exempt_encryption from inputs."""
|
|
224
|
+
return {"uses_non_exempt": _pick(inp["USES_NON_EXEMPT"], default="false")}
|
|
254
225
|
|
|
255
226
|
|
|
256
227
|
def collect_inputs() -> dict:
|
|
@@ -272,15 +243,17 @@ def main() -> None:
|
|
|
272
243
|
fail("GITHUB_ENV not set; this script must run inside a GitHub Actions step")
|
|
273
244
|
env_file = Path(env_file_path)
|
|
274
245
|
|
|
275
|
-
cfg = load_config(workspace, os.environ.get("CONFIG_PATH", "ci.config.yaml"))
|
|
276
246
|
inputs = collect_inputs()
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
app = resolve_app(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
247
|
+
creds = emit_credentials(env_file, workspace)
|
|
248
|
+
xc = resolve_xcode(workspace, inputs)
|
|
249
|
+
xc_values = {k: v[0] for k, v in xc.items()}
|
|
250
|
+
app = resolve_app(
|
|
251
|
+
inputs, creds, scripts_dir,
|
|
252
|
+
workspace=workspace, xcode=xc_values,
|
|
253
|
+
)
|
|
254
|
+
tf = resolve_testflight(inputs)
|
|
255
|
+
ios = resolve_ios(inputs)
|
|
256
|
+
tests = resolve_tests(inputs)
|
|
284
257
|
|
|
285
258
|
derived = [
|
|
286
259
|
("CFG_PROJECT", xc["project"]),
|
|
@@ -305,9 +278,7 @@ def main() -> None:
|
|
|
305
278
|
|
|
306
279
|
# Persist whatsNew to a file under $RUNNER_TEMP so downstream steps can
|
|
307
280
|
# read raw multi-line content without any GitHub Actions ${{ }} YAML
|
|
308
|
-
# interpolation mangling embedded newlines.
|
|
309
|
-
# the same content for backward compatibility; the file is the source
|
|
310
|
-
# of truth.
|
|
281
|
+
# interpolation mangling embedded newlines.
|
|
311
282
|
whats_new_value = tf["whats_new"][0]
|
|
312
283
|
runner_temp = os.environ.get("RUNNER_TEMP") or str(workspace)
|
|
313
284
|
whats_new_path = Path(runner_temp) / "whats_new.txt"
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# iOS TestFlight CI configuration — read by daemux/daemux-plugins/.github/actions/ios-native-testflight
|
|
2
|
-
# Place this at the repo root as ci.config.yaml.
|
|
3
|
-
# Also place your ASC API key at creds/AuthKey_<KEY_ID>_Issuer_<ISSUER_UUID>.p8
|
|
4
|
-
|
|
5
|
-
app:
|
|
6
|
-
bundle_id: "com.example.myapp" # REQUIRED
|
|
7
|
-
team_id: "ABCDE12345" # optional — auto-derived from ASC API key when omitted
|
|
8
|
-
app_store_apple_id: "" # optional — auto-discovered via ASC API by bundle_id
|
|
9
|
-
|
|
10
|
-
xcode:
|
|
11
|
-
project: "" # auto-detected if exactly one *.xcodeproj at root
|
|
12
|
-
workspace: "" # wins over project when set
|
|
13
|
-
scheme: "MyApp" # REQUIRED — no safe auto-detect
|
|
14
|
-
configuration: "Release" # default: Release
|
|
15
|
-
profile_name: "" # default: "<scheme> CI"
|
|
16
|
-
|
|
17
|
-
ios:
|
|
18
|
-
uses_non_exempt_encryption: false # false | true | "" to skip write
|
|
19
|
-
|
|
20
|
-
testflight:
|
|
21
|
-
whats_new: |
|
|
22
|
-
- Improved performance
|
|
23
|
-
- Bug fixes
|
|
24
|
-
- Enhanced security
|
|
25
|
-
locale: "en-US"
|
|
26
|
-
|
|
27
|
-
ci:
|
|
28
|
-
run_tests: false
|
|
29
|
-
test_command: "" # optional
|
|
30
|
-
test_destination: "platform=iOS Simulator,name=iPhone 15"
|