#!/bin/bash
# ======= 可配置参数 =======
APP_NAME="maxxhealth" # CodePush App 名称
DEPLOYMENT="Staging" # CodePush 环境:Staging / Production
VERSION="1.5.9" # 对应 iOS 项目 Info.plist 的 CFBundleShortVersionString
BUNDLE_DIR="../../codepush/bundle" # 输出目录
ENTRY_FILE="index.js" # RN 入口文件
PLATFORM="ios" # 平台
# ===========================
# 清理旧 bundle
rm -rf $BUNDLE_DIR
mkdir -p $BUNDLE_DIR
echo "📦 开始打包 React Native Bundle..."
npx react-native bundle \
--entry-file $ENTRY_FILE \
--platform $PLATFORM \
--dev false \
--bundle-output $BUNDLE_DIR/main.jsbundle \
--assets-dest $BUNDLE_DIR \
--sourcemap-output $BUNDLE_DIR/main.jsbundle.map
if [ $? -ne 0 ]; then
echo "❌ 打包失败,请检查错误信息"
exit 1
fi
echo "🚀 开始发布 CodePush 更新..."
code-push release \
$APP_NAME \
$BUNDLE_DIR \
$VERSION \
-d $DEPLOYMENT \
--description "iOS $VERSION 自动发布包"
if [ $? -ne 0 ]; then
echo "❌ 发布失败,请检查 CodePush 配置"
exit 1
fi
echo "✅ CodePush 发布完成!"
使用时
✅ 使用方法:
1. 保存为 codepush-ios.sh。
2. 给予可执行权限:
chmod +x codepush-ios.sh
3. 执行脚本:
./codepush-ios.sh