feat(api): enhance public APK endpoint to return semantic version from OTA bundle
All checks were successful
Build Updates Server / build (push) Successful in 1m1s
Build Updates Server / build-docker (push) Successful in 36m50s

The PublicLatestAPK endpoint now reads the expoConfig.json from the OTA bundle
to extract the actual semantic version (expo.version) instead of returning
the runtimeVersion as the version name. Falls back to runtimeVersion if
expoConfig.json is not available.
This commit is contained in:
lafay
2026-06-17 20:06:07 +08:00
parent e9a6b7a169
commit 7fa2431a4a
2 changed files with 32 additions and 1 deletions

View File

@@ -300,9 +300,18 @@ func (h *Handler) PublicLatestAPK(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusNotFound, map[string]any{"error": "No APK available"})
return
}
// versionName 优先从同 runtimeVersion 的 OTA bundle 里读取 expoConfig.json
// CI 在 publish OTA 时会把 expoConfig.json 打入 zip
versionName := h.svc.GetAPKVersionName(apk.RuntimeVersion)
if versionName == "" {
// 兜底:没有 expoConfig 时退回 runtimeVersion不应该发生但保底
versionName = apk.RuntimeVersion
}
resp := model.LatestAPKResponse{
RuntimeVersion: apk.RuntimeVersion,
VersionName: apk.RuntimeVersion,
VersionName: versionName,
Size: apk.Size,
DownloadURL: fmt.Sprintf("%s/api/apk/download?runtimeVersion=%s", h.svc.Hostname(), apk.RuntimeVersion),
CreatedAt: apk.CreatedAt.Format(time.RFC3339),