美文网首页
APP快速打包

APP快速打包

作者: 张文进 | 来源:发表于2023-10-19 16:11 被阅读0次

    #使用方法

    if [ ! -d ./IPADir ];

    then

    mkdir -p IPADir;

    fi

    #工程绝对路径

    project_path=项目路径

    #echo "环境:"

    #read envir_desc

    echo "更新内容:"

    read update_desc

    #工程名

    project_name=HuiHongShop

    #scheme名

    scheme_name=HuiHongShop

    product_name=HuiHongShop

    #打包模式 Debug/Release

    development_mode=Release

    #蒲公英参数

    user_key=a50db512f59be9edc27fbd882bf7cf25

    api_key=dce54dd23345f6b59f1b684623e83e63

    current_path=$(cd `dirname $0`; pwd)

    #build文件夹路径

    build_path=${current_path}/build

    #plist文件所在路径

    exportOptionsPlistPath=${current_path}/ExportOptions.plist

    #导出.ipa文件所在路径

    exportIpaPath=${current_path}/IPADir/${development_mode}

    ##json解析函数

    function jsonParse() { # $1 $2  json lable

        JSON_CONTENT=$1

        KEY='"'$2'":'

        echo ${JSON_CONTENT} | awk -F  ${KEY}  '{print $2}' | awk -F '"' '{print $2}'

    }

    ##删除斜杠'\'

    function trimSlash() {

        TEXT=$1

        echo ${TEXT//'\'/''}

    }

    echo "第一步,进入项目工程文件"

    cd $project_path

    echo '正在清理工程'

    xcodebuild \

    clean -configuration ${development_mode} -quiet  || exit

    echo '清理完成'

    echo '正在编译工程:'${development_mode}

    xcodebuild \

    archive -workspace ${project_path}/${project_name}.xcworkspace \

    -scheme ${scheme_name} \

    -configuration ${development_mode} \

    -archivePath ${build_path}/${project_name}.xcarchive  -quiet  || exit

    echo '编译完成'

    echo '开始ipa打包'

    xcodebuild -exportArchive -archivePath ${build_path}/${project_name}.xcarchive \

    -configuration ${development_mode} \

    -exportPath ${exportIpaPath} \

    -exportOptionsPlist ${exportOptionsPlistPath} \

    -quiet || exit

    if [ -e $exportIpaPath/$product_name.ipa ]; then

    echo 'ipa包已导出'

        echo '发布ipa包到 =============蒲公英平台============='

        RESPONSE=$(curl -F "file=@$exportIpaPath/$product_name.ipa" -F "uKey=${user_key}" -F "_api_key=${api_key}" -F "updateDescription=${update_desc}" https://www.xcxwo.com/apiv2/app/upload)

        if [ $? -eq 0 ];then

        echo "=============提交蒲公英成功 ============="

        appQRCodeURL=$(trimSlash $(jsonParse "${RESPONSE}" "buildQRCodeURL"))

        appVersion=$(jsonParse "${RESPONSE}" "buildVersion")

        appBuildVersion=$(jsonParse "${RESPONSE}" "buildBuildVersion")

        #通知到企业微信

        curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=f5012a7a-fa0a-4718-a65b-cf92f0f380a8' \

            -H 'Content-Type: application/json' \

            -d '

            {

                "msgtype": "markdown",

                "markdown": {

                    "content":"**'"$product_name"'版本更新**  \n ![点击打开二维码下载]('"$appQRCodeURL"')  \n  **版本:** '"$appVersion"' (build '"$appBuildVersion"')  \n  **说明:** '"$update_desc"'"

                    }

            }'

        else

        echo "=============提交蒲公英失败 ============="

        fi

    #open $exportIpaPath

    else

    echo 'ipa包导出失败 '

    fi

    echo '打包ipa完成  '

    exit 0

    相关文章

      网友评论

          本文标题:APP快速打包

          本文链接:https://www.haomeiwen.com/subject/quuhidtx.html