支持 App Store 送检任务按需排除 IPA 符号文件

This commit is contained in:
shenlei
2026-11-23 10:06:23 +09:00
parent d13fcfcdea
commit ab5793631c
9 changed files with 31 additions and 1 deletions
+1
View File
@@ -22,6 +22,7 @@ def get_db():
def _migrate_db(): def _migrate_db():
"""简单的数据库迁移:为旧表添加缺失的列""" """简单的数据库迁移:为旧表添加缺失的列"""
migrations = [ migrations = [
("tasks", "exclude_symbols", "BOOLEAN DEFAULT 0"),
("tasks", "branch", "VARCHAR DEFAULT 'main'"), ("tasks", "branch", "VARCHAR DEFAULT 'main'"),
("tasks", "ref_type", "VARCHAR DEFAULT 'branch'"), ("tasks", "ref_type", "VARCHAR DEFAULT 'branch'"),
("tasks", "error_category", "VARCHAR"), ("tasks", "error_category", "VARCHAR"),
+1
View File
@@ -15,6 +15,7 @@ class Task(Base):
build_type = Column(String, nullable=False) build_type = Column(String, nullable=False)
scheme_id = Column(String, nullable=False) scheme_id = Column(String, nullable=False)
scheme_name = Column(String, nullable=False) scheme_name = Column(String, nullable=False)
exclude_symbols = Column(Boolean, default=False)
obfuscation = Column(Boolean, default=False) obfuscation = Column(Boolean, default=False)
branch = Column(String, default="main") # 分支名或 Tag 名,由 ref_type 区分 branch = Column(String, default="main") # 分支名或 Tag 名,由 ref_type 区分
ref_type = Column(String, default="branch") # branch/tag ref_type = Column(String, default="branch") # branch/tag
+1
View File
@@ -73,6 +73,7 @@ async def create_task(task: TaskCreate, request: Request, user: dict = Depends(g
build_type=task.build_type, build_type=task.build_type,
scheme_id=task.scheme_id, scheme_id=task.scheme_id,
scheme_name=scheme.get("displayName") or scheme_name, scheme_name=scheme.get("displayName") or scheme_name,
exclude_symbols=task.build_type == "App_Store" and task.exclude_symbols,
obfuscation=task.obfuscation, obfuscation=task.obfuscation,
branch=task.branch, branch=task.branch,
ref_type=ref_type, ref_type=ref_type,
+1
View File
@@ -9,6 +9,7 @@ class TaskCreate(BaseModel):
app_id: str app_id: str
build_type: str build_type: str
scheme_id: str scheme_id: str
exclude_symbols: bool = False
obfuscation: bool = False obfuscation: bool = False
branch: str = "main" branch: str = "main"
+1
View File
@@ -753,6 +753,7 @@ async def generate_config(task_id: str, task, build_dir: Path) -> dict:
"SCHEME": scheme.get("name", ""), "SCHEME": scheme.get("name", ""),
"OSS_FLODER": scheme.get("ossFloder", ""), "OSS_FLODER": scheme.get("ossFloder", ""),
"BUILD_TYPE": task.build_type, "BUILD_TYPE": task.build_type,
"EXCLUDE_SYMBOLS": bool(task.exclude_symbols),
"ENABLE_OBFUSCATION": task.obfuscation, "ENABLE_OBFUSCATION": task.obfuscation,
} }
+2
View File
@@ -24,6 +24,8 @@ def _artifact_stem(config: dict) -> str:
return f"{config.get('APPID', 'app')}_{version}" return f"{config.get('APPID', 'app')}_{version}"
branch = re.sub(r"[^A-Za-z0-9._-]+", "_", config.get("SOURCE_BRANCH", "main")).strip("._-") branch = re.sub(r"[^A-Za-z0-9._-]+", "_", config.get("SOURCE_BRANCH", "main")).strip("._-")
build_type = "appstore" if config.get("BUILD_TYPE") == "App_Store" else "adhoc" build_type = "appstore" if config.get("BUILD_TYPE") == "App_Store" else "adhoc"
if build_type == "appstore" and config.get("EXCLUDE_SYMBOLS"):
build_type += "_nosymbols"
return f"{config.get('APPID', 'app')}_{version}_{branch or 'main'}_{build_type}" return f"{config.get('APPID', 'app')}_{version}_{branch or 'main'}_{build_type}"
+2
View File
@@ -113,6 +113,8 @@ def _write_export_options(build_dir: Path, config: dict):
"stripSwiftSymbols": True, "stripSwiftSymbols": True,
"thinning": "<none>", "thinning": "<none>",
} }
if data["method"] == "app-store-connect" and config.get("EXCLUDE_SYMBOLS"):
data["uploadSymbols"] = False
with (build_dir / "exportOptions.plist").open("wb") as f: with (build_dir / "exportOptions.plist").open("wb") as f:
plistlib.dump(data, f) plistlib.dump(data, f)
+8
View File
@@ -51,6 +51,12 @@
</optgroup> </optgroup>
</select> </select>
</div> </div>
<div v-if="form.build_type === 'App_Store'" class="form-group">
<div class="checkbox-group">
<input id="exclude-symbols" v-model="form.exclude_symbols" type="checkbox">
<label for="exclude-symbols">安全送检:IPA 不包含 Symbols 目录</label>
</div>
</div>
<div v-if="supportsObfuscation" class="form-group"> <div v-if="supportsObfuscation" class="form-group">
<label>代码混淆</label> <label>代码混淆</label>
<div class="checkbox-group"> <div class="checkbox-group">
@@ -203,6 +209,7 @@ const form = ref({
app_id: '', app_id: '',
build_type: '', build_type: '',
scheme_id: '', scheme_id: '',
exclude_symbols: false,
obfuscation: false, obfuscation: false,
branch: 'main', branch: 'main',
}) })
@@ -392,6 +399,7 @@ const submitTask = async () => {
app_id: '', app_id: '',
build_type: '', build_type: '',
scheme_id: '', scheme_id: '',
exclude_symbols: false,
obfuscation: false, obfuscation: false,
branch: branches.value[0] || 'main', branch: branches.value[0] || 'main',
} }
+14 -1
View File
@@ -3,7 +3,7 @@ import plistlib
import pytest import pytest
from backend.services.project_patcher import ProjectPatchError, apply_project_config from backend.services.project_patcher import ProjectPatchError, _write_export_options, apply_project_config
def test_apply_project_config_without_branch_autopacking(tmp_path): def test_apply_project_config_without_branch_autopacking(tmp_path):
@@ -206,3 +206,16 @@ def test_readoor_definition_has_dict_server_fields():
assert keys == ["DICT_SERVERURL", "DICT_SERVERHTTPSURL", "DICT_UCSERVERURL", assert keys == ["DICT_SERVERURL", "DICT_SERVERHTTPSURL", "DICT_UCSERVERURL",
"DICT_RECORDSERVERURL", "DICT_LOGSERVERURL"] "DICT_RECORDSERVERURL", "DICT_LOGSERVERURL"]
assert get_definition("other", {"patcher": "generic"})["server_fields"] == [] assert get_definition("other", {"patcher": "generic"})["server_fields"] == []
@pytest.mark.parametrize("no_cert", [False, True])
@pytest.mark.parametrize("build_type,exclude,expected", [
("App_Store", True, False),
("App_Store", False, None),
("Ad_Hoc", True, None),
])
def test_export_symbols_option(tmp_path, no_cert, build_type, exclude, expected):
config = {"NO_CERT": no_cert, "BUILD_TYPE": build_type, "EXCLUDE_SYMBOLS": exclude}
_write_export_options(tmp_path, config)
options = plistlib.loads((tmp_path / "exportOptions.plist").read_bytes())
assert options.get("uploadSymbols") is expected