• [iOS-Release] 自动修改构建号


    参考:https://www.jianshu.com/p/2167f755c47e

    关于发布蒲公英的脚本处理:

        需要登陆蒲公英,获取api key和user key,如下:

        akey="1213467225788"
        ukey="1287311212132"
        boot_passwd="test"
        des_msg=`git log -1 --pretty=%B`
        ipa_path="HPPlay_Release_Payload.ipa"
        upload_url="http://www.pgyer.com/apiv1/app/upload"
        echo uploading $ipa_path to pgyer .....
        curl -F "file=@${ipa_path}" -F "uKey=${ukey}" -F "_api_key=${akey}" -F "updateDescription=${des_msg}" -F "password=${boot_passwd}" $upload_url

    场景:ios app发版前,我们都要经过多轮测试,由于都是在手机上安装,所以我们更加倾向于将包传到蒲公英,从蒲公英扫描下载,这是一种很快捷的方式,但是有个缺点是,安装好的包,如果开发不修改版本号(比如4.0.0),测试看到的永远都是同一个版本号(比如4.0.0),根本看不出来是第几次出包第几次测试,我们就想要是版本号后面能加上第几次构建就好了,比如4.0.0_1,4.0.0_2 ,这样就很明白了。

    先给大家看看效果图:

    下面介绍如何实现:

    原理:找到代码中定义版本号的地方,修改版本号增加“_递增的数字”,如果版本不一样的,数字又重新开始递增。我们可以将上一次的版本和递增数字写入到一个记录文件中,修改版本的部分,肯定是在编译之前做,我的脚本如下:

    echo ========ios ipa modify build times for pgyer=========
    echo path=`pwd`
    #info文件路径
    info_file=HPPlayTVAssistant/HPPlayTVAssistant/Info.plist
    [ ! -f $info_file ] && echo $info_file not exist && exit 1
    echo build command /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' $info_file
    #这里命令会得到${MARKETING_VERSION},是我们定义在其他地方的宏
    build_n=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' $info_file |awk -F "(" '{print $2}' |awk -F ")" '{print $1}'`
    echo build_n=$build_n
    if [ "$build_n" == "MARKETING_VERSION" ];then #查找工程文件中这个宏对应的值
    cur_ver_tmp=`grep -r MARKETING_VERSION HPPlayTVAssistant/HPPlayTVAssistant.xcodeproj/project.pbxproj |sed -n 1p`
    echo cur_ver_tmp=$cur_ver_tmp
    cur_ver=`echo $cur_ver_tmp |awk -F "= " '{print $2}' |awk -F ";" '{print $1}'`
    else
    cur_ver=$build_n
    fi
    echo cur_ver=$cur_ver
    #查看记录文件ios_pyger_last_build中的版本号(文件默认初始值是0_0,第一个0是版本号,第二个是构建次数)
    last_version=`cat /Users/dabaozhuanyong/lebo/ios_pyger_last_build |awk -F "_" '{print $1}'`
    #如果版本有变化,记录文件再写回初始值0_0
    [ "$last_version" != "$cur_ver" ] && echo different version && echo 0_0 > /Users/dabaozhuanyong/lebo/ios_pyger_last_build
    #获取构建次数(下划线后面的字符)
    last_build=`cat /Users/dabaozhuanyong/lebo/ios_pyger_last_build |awk -F "_" '{print $2}'`
    #构建次数+1
    new_build=`expr $last_build + 1 `
    echo "$cur_ver"_"$new_build" > /Users/dabaozhuanyong/lebo/ios_pyger_last_build
    new_ver_name="$cur_ver"_"$new_build"
    echo new_ver_name=$new_ver_name
    #修改info.plist文件中的版本号
    /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $new_ver_name" ${info_file}
    echo check as follow:
    /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' $info_file

  • 相关阅读:
    深入理解DOM事件类型系列第四篇——剪贴板事件
    深入理解DOM事件机制系列第四篇——事件模拟
    利用select实现年月日三级联动的日期选择效果
    深入理解表单脚本系列第四篇——选择框脚本
    存储过程返回布尔值以及C#相关处理
    Type 'Insus.NET.PictureObject' in Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
    打开Windows10网络发现或是文件打印共享
    反射(Reflection)的SetValue遇上DBNULL转换为string
    MS SQL中使用UPDATE ... INNER JOIN ...
    Visual Studio 2015正式企业(Enterprise)版
  • 原文地址:https://www.cnblogs.com/zndxall/p/12197678.html
Copyright © 2020-2023  润新知