Files
life-echo/app-expo/scripts/ios-prebuild.sh

76 lines
2.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# 本机 iOS Release切换 env → expo prebuild → 打开 Xcode 打 Archive 上传 TestFlight。
#
# 用法(在仓库任意目录):
# app-expo/scripts/ios-prebuild.sh staging
# app-expo/scripts/ios-prebuild.sh production
#
# 或通过 npm在 app-expo 目录):
# npm run ios:prebuild:staging
# npm run ios:prebuild:production
#
# Xcode 内后续步骤(脚本不会自动执行):
# 1. 选 Any iOS Device或 Generic iOS Device
# 2. Product → Archive
# 3. Distribute App → App Store Connect → Upload进入 TestFlight
set -euo pipefail
ENV="${1:-}"
if [[ -z "$ENV" ]]; then
echo "Usage: $(basename "$0") <staging|production|development>" >&2
exit 1
fi
case "$ENV" in
staging | production | development) ;;
*)
echo "Unknown environment: $ENV (expected staging, production, or development)" >&2
exit 1
;;
esac
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
feat: OpenTelemetry LGTM observability, dev tooling, and memoir UX fixes (#31) * add staging ios app build script * feat(api): add OpenTelemetry LGTM stack for local observability Wire OTel traces, metrics, and logs through a collector to Tempo, Prometheus, and Loki, with custom LLM instrumentation, dev compose overlay, Grafana provisioning, env templates, and development.sh auto-start. Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expand observability, harden dev tooling, and fix expo staging UX Add business and LLM Prometheus metrics with Grafana dashboards, alerting, and a metrics verification script. Wire telemetry through adapters and core LLM paths, and document the local LGTM workflow. Fix development.sh for macOS bash 3.2, open Grafana and eval-web in Chrome, and repair eval-web auto-open (unbound EVAL_WEB_BROWSER_SCHEDULED). Merge internal-eval into the main dev script with improved compose handling. Require EXPO_PUBLIC_* at build time, improve iOS HTTP ATS for staging IPs, show memoir empty state instead of load errors when no chapters exist, and add jest env setup plus chapter list response normalization. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: enable Grafana Assistant Cursor plugin Co-authored-by: Cursor <cursoragent@cursor.com> * fix: memoir empty state and repair withdrawn 0020_chapters_book_id stamp Show empty memoir UI when the chapter list succeeds with no items; treat auth/404 as non-fatal. Extend alembic revision repair so local dev DBs stamped with the removed 0020_chapters_book_id migration can roll back and upgrade to 0019. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Kevin <kevin@brighteng.org> Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-20 15:12:21 +08:00
echo "==> Switching to env/${ENV} → .env"
npm run use-env -- "$ENV"
feat: OpenTelemetry LGTM observability, dev tooling, and memoir UX fixes (#31) * add staging ios app build script * feat(api): add OpenTelemetry LGTM stack for local observability Wire OTel traces, metrics, and logs through a collector to Tempo, Prometheus, and Loki, with custom LLM instrumentation, dev compose overlay, Grafana provisioning, env templates, and development.sh auto-start. Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expand observability, harden dev tooling, and fix expo staging UX Add business and LLM Prometheus metrics with Grafana dashboards, alerting, and a metrics verification script. Wire telemetry through adapters and core LLM paths, and document the local LGTM workflow. Fix development.sh for macOS bash 3.2, open Grafana and eval-web in Chrome, and repair eval-web auto-open (unbound EVAL_WEB_BROWSER_SCHEDULED). Merge internal-eval into the main dev script with improved compose handling. Require EXPO_PUBLIC_* at build time, improve iOS HTTP ATS for staging IPs, show memoir empty state instead of load errors when no chapters exist, and add jest env setup plus chapter list response normalization. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: enable Grafana Assistant Cursor plugin Co-authored-by: Cursor <cursoragent@cursor.com> * fix: memoir empty state and repair withdrawn 0020_chapters_book_id stamp Show empty memoir UI when the chapter list succeeds with no items; treat auth/404 as non-fatal. Extend alembic revision repair so local dev DBs stamped with the removed 0020_chapters_book_id migration can roll back and upgrade to 0019. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Kevin <kevin@brighteng.org> Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-20 15:12:21 +08:00
# Release Archive 时 NODE_ENV=productionExpo 会加载根目录 .env.production 并覆盖 .env
for legacy in .env.production .env.staging .env.development; do
if [[ -f "$legacy" ]]; then
echo "::error::Found legacy $legacy — it overrides use-env on Release builds. Use app-expo/env/ templates only." >&2
exit 1
fi
done
echo "==> expo prebuild --platform ios --clean"
npx expo prebuild --platform ios --clean
shopt -s nullglob
WORKSPACES=(ios/*.xcworkspace)
shopt -u nullglob
if [[ ${#WORKSPACES[@]} -eq 0 ]]; then
echo "No ios/*.xcworkspace found after prebuild." >&2
exit 1
fi
if [[ ${#WORKSPACES[@]} -gt 1 ]]; then
echo "Multiple workspaces found; opening the first: ${WORKSPACES[0]}" >&2
fi
echo "==> Opening ${WORKSPACES[0]}"
open "${WORKSPACES[0]}"
cat <<EOF
Done. In Xcode:
• Select "Any iOS Device" (or a connected device)
• Product → Archive
• Window → Organizer → Distribute App → App Store Connect
Environment: ${ENV}
API URL: $(grep -E '^EXPO_PUBLIC_API_URL=' .env 2>/dev/null | cut -d= -f2- || echo '(see .env)')
EOF