创建部署
code-push login
code-push app add MyAppIOS ios react-native
code-push deployment ls MyAppIOS -k
code-push app add MyAppAndroid android react-native
code-push deployment ls MyAppAndroid -k
build.gradle里面增加配置
signingConfigs {
release {
keyAlias 'key0'
keyPassword ''
storeFile file('../')
storePassword ''
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
debug{
}
releaseStaging {
minifyEnabled enableProguardInReleaseBuilds
buildConfigField "String", "CODEPUSH_KEY", '"key"'
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
release {
minifyEnabled enableProguardInReleaseBuilds
buildConfigField "String", "CODEPUSH_KEY", '"key"'
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
Android程序里面添加
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)
);
}
react native代码
import CodePush from "react-native-code-push";
class App extends Component<{}> {
componentWillMount(){
CodePush.disallowRestart();//页面加载的禁止重启,在加载完了可以允许重启
}
componentDidMount(){
CodePush.allowRestart();//在加载完了可以允许重启
}
let codePushOptions = { checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME };
App = CodePush(codePushOptions)(App);
export default App;
打包
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
cd android && ./gradlew assembleRelease
code-push release-react MyAppAndroid android --t 1.0.0 --dev false --d Production --des "1.修复了已知BUG" --m true
// 账户相关
code-push login 登陆
code-push loout 注销
code-push access-key ls 列出登陆的token
code-push access-key rm <accessKye> 删除某个 access-key
// app操作相关
code-push app add <appName> <platform> react-native 在账号里面添加一个新的app
code-push app remove 或者 rm 在账号里移除一个 app
code-push app rename 重命名一个存在 app
code-push app list 或则 ls 列出账号下面的所有 app
code-push app transfer 把app的所有权转移到另外一个账号
// 应用信息相关
code-push deployment add <appName> 部署
code-push deployment rm <appName> 删除部署
code-push deployment rename <appName> 重命名
code-push deployment ls <appName> 列出应用的部署情况
code-push deployment ls <appName> -k 查看部署的key
code-push deployment history <appName> <deploymentName> 查看历史版本
// 发布
code-push release-react <appName> <platform> -t 版本 -d 环境 --des 描述 -m true (强制更新)
// 清除历史部署记录
code-push deployment clear <appName> Production or Staging
// 回滚
code-push rollback <appName> Production --targetRelease v4(codepush服务部署的版本号)
网友评论