最近一直在用codepush,为了方便使用,搞了个脚本,分享一下。
创建一个命名为codepush_appcenter_realse.sh的脚步
里面内容如下:
#!/bin/bash
#查看账号app列表
lookAppsList () {
appcenter apps list
}
#查看热推记录
lookPushHistory () {
read -p "请输入CodePush需要部署的应用名称 组织/名称:" ownerNameAppName
appcenter codepush deployment list -a $ownerNameAppName
}
#创建应用
createCodePushApp () {
echo ""
read -p "该脚本需要放在与ios同级目录下 (rn根目录)已确认? y/n:" state
echo "$state"
if [ "$state" = "y" ]
then
echo "appcenter code push createapp!"
read -p "请输入CodePushApp名称(英文):" appname
read -p "请输入平台 iOS/Android:" operatingSystem
#read -p "请输入codepush应用平台 默认React-Native:" codePushPlatform
appcenter apps create -d $appname -o $operatingSystem -p React-Native
sleep 1.0
lookAppsList
sleep 1.0
echo "appcenter code push add deployment Staging!"
read -p "请输入CodePush需要部署的应用名称 组织/名称:" ownerNameAppName
appcenter codepush deployment add -a $ownerNameAppName Staging
echo "deployment Stagging创建成功Done !"
sleep 1.0
echo "appcenter code push add deployment Production!"
appcenter codepush deployment add -a $ownerNameAppName Production
echo "deployment Production创建成功Done !"
sleep 1.0
echo "deployment 查看部署列表!"
appcenter codepush deployment list -a $ownerNameAppName
else
echo "请将该脚本需要放在与ios同级目录下 (rn根目录)"
fi
}
releasePushRun () {
echo ""
read -p "该脚本需要放在与ios同级目录下 (rn根目录)已确认? y/n:" state
echo "$state"
if [ "$state" = "y" ]
then
echo "appcenter code push realse buddle!"
read -p "请输入CodePushApp名称(英文) 组织/名称:" appname
read -p "请输入平台 ios/android:" platform
read -p "请输入rn本更新包面向的旧版本号:" rnversion
read -p "请输入rn环境(Production/Staging):" production
read -p "请输入更新内容:" rnversioncontent
read -p "是否需要强制更新(true/false):" mupdate
appcenter codepush release-react -a $appname -t $rnversion -d $production --description $rnversioncontent -m $mupdate -c ./CodePush --sourcemap-output --output-dir ./build
echo "rn App realse ios main bundle Done !"
else
echo "请将该脚本需要放在与ios同级目录下 (rn根目录)"
fi
}
# 输入使用类型
publishRun () {
# 输入使用类型
echo "\033[36;1m请选择使用类型(输入序号, 按回车即可) \033[0m"
echo "\033[33;1m1. 创建app \033[0m"
echo "\033[33;1m2. 开始热推 \033[0m"
echo "\033[33;1m3. 查看热推历史 \033[0m"
echo "\033[33;1m4. 查看app列表 \033[0m"
if [ ${#parameter_upload} == 0 ]
then
#读取用户输入
read parameter_upload
sleep 0.5
fi
if [ "$parameter_upload" == "1" ]; then
echo "\033[32m****************\n您选择了创建app\n****************\033[0m\n"
elif [ "$parameter_upload" == "2" ]; then
echo "\033[32m****************\n您选择了开始热推\n****************\033[0m\n"
elif [ "$parameter_upload" == "3" ]; then
echo "\033[32m****************\n您选择了查看热推历史\n****************\033[0m\n"
elif [ "$parameter_upload" == "4" ]; then
echo "\033[32m****************\n您选择了查看app列表\n****************\033[0m\n"
else
echo "\n\033[31;1m**************** 您输入的参数,无效请重新输入!!! ****************\033[0m\n"
parameter_upload=""
publishRun
fi
}
publishRun
#创建app
if [ "$parameter_upload" == "1" ]
then
#创建app
createCodePushApp
fi
#开始热推
if [ "$parameter_upload" == "2" ]
then
#开始热推
releasePushRun
fi
#查看热推历史
if [ "$parameter_upload" == "3" ]
then
#查看热推历史
lookPushHistory
fi
#查看app列表
if [ "$parameter_upload" == "4" ]
then
#查看app列表
lookAppsList
fi
网友评论