From 649f59eeed6f1aa31ee138d454d2730328643d63 Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Wed, 23 Jul 2014 14:05:14 +0800 Subject: [PATCH 1/7] update fir upload url --- ipa-publish-fir | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/ipa-publish-fir b/ipa-publish-fir index 6bf80fd..d922dc0 100755 --- a/ipa-publish-fir +++ b/ipa-publish-fir @@ -49,8 +49,9 @@ email_smtphost=smtp.exmail.qq.com #fir 相关url fir_domain="http://fir.im" -fir_lookup_url="$fir_domain/api/upload_url" +fir_lookup_url="$fir_domain/api/v2/app/info" fir_finish_url="$fir_domain/api/finish" +fir_token="nu4s06BnAoHqugPRdEShv0lfRq7e9HahWL1kybwq" #获取shell文件所在的绝对路径 current_path=$(pwd) @@ -161,34 +162,41 @@ if [ $git_log_limit != 0 ];then git_log=`git log --pretty=format:"%s" -$git_log_limit | tr -d " " | awk '{printf "%s
",$1}'` fi +echo "===== bundleIdentifier is $bundleIdentifier ======" #到fir api 查询具体的包上传地址 echo "Fetching upload url from fir..." -response=`curl -L "$fir_lookup_url?appid=$bundleIdentifier"` +echo "do fetch $fir_lookup_url/$bundleIdentifier?token=$fir_token" +response=`curl "$fir_lookup_url/$bundleIdentifier?token=$fir_token"` +echo $response #网络请求结果判断 rtnValue=$? if [ $rtnValue != 0 ];then exit 1 fi -fir_publish_url=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['postFile']"` -fir_publish_icon_url=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['postIcon']"` -fir_publish_short_name=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` +fir_publish_url=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['bundle']['pkg']['url']"` +echo $fir_publish_url +fir_publish_key=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['bundle']['pkg']['key']"` +fir_publish_token=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['bundle']['pkg']['token']"` +realShort=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` +echo $realShort #上传ipa包,并获取最终的url short name echo "Uploading the ipa file..." -curl -LT ${target_name}.ipa "$fir_publish_url" +curl -F file=@${target_name}.ipa -F "key=$fir_publish_key" -F "token=$fir_publish_token" $fir_publish_url rtnValue=$? if [ $rtnValue != 0 ];then exit 1 fi echo "Finishing uploading and filling in the app information..." -response=`curl -L "$fir_finish_url?appid=$bundleIdentifier&short=$fir_publish_short_name&version=$bundleShortVersion($bundleVersion)&name=${ipa_name}_v${bundleShortVersion}&changelog=$change_msg$git_log"` -realShort=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` +# response=`curl -L "$fir_finish_url?appid=$bundleIdentifier&short=$fir_publish_short_name&version=$bundleShortVersion($bundleVersion)&name=${ipa_name}_v${bundleShortVersion}&changelog=$change_msg$git_log"` +# realShort=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` #拼接完整的下载url,并在浏览器中打开 pulish_url=$fir_domain/$realShort -open $pulish_url +echo $pulish_url +# open $pulish_url build_time=`date` From 84c5b71a78bced57ffc4fea16693b41f507d334f Mon Sep 17 00:00:00 2001 From: yangfan12 Date: Mon, 18 Aug 2014 22:32:58 +0800 Subject: [PATCH 2/7] Update app info after uploading. --- ipa-publish-fir | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ipa-publish-fir b/ipa-publish-fir index d922dc0..3e8b91a 100755 --- a/ipa-publish-fir +++ b/ipa-publish-fir @@ -27,7 +27,6 @@ # 修改人:Shannon Chou # 修改内容:在原ipa-publish 的基础上改为ipa-publish-fir,用于将app 发布到fir.im上测试 #-------------------------------------------- - #须配置内容 start #以下是邮箱的相关设置,jiecao.fm 提供了一个可以直接使用的邮箱账号,请不要去更改邮箱密码,以便他人使用 @@ -134,6 +133,8 @@ target_name=$(/usr/libexec/PlistBuddy -c "print CFBundleName" ${app_infoplist_pa #取CFBundleDisplayName display_name=$(/usr/libexec/PlistBuddy -c "print CFBundleDisplayName" ${app_infoplist_path}) +echo "App $display_name版本号为: $bundleShortVersion, 构建号为: $bundleVersion." + #删除临时文件夹 cd .. rm -rf ${tmpfoldername} @@ -179,7 +180,9 @@ echo $fir_publish_url fir_publish_key=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['bundle']['pkg']['key']"` fir_publish_token=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['bundle']['pkg']['token']"` realShort=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` -echo $realShort +#第一次请求得到的 Appid, 用来最后更新 App 的信息. +fir_app_id=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['id']"` + #上传ipa包,并获取最终的url short name echo "Uploading the ipa file..." @@ -190,8 +193,9 @@ exit 1 fi echo "Finishing uploading and filling in the app information..." -# response=`curl -L "$fir_finish_url?appid=$bundleIdentifier&short=$fir_publish_short_name&version=$bundleShortVersion($bundleVersion)&name=${ipa_name}_v${bundleShortVersion}&changelog=$change_msg$git_log"` -# realShort=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` +echo "Updateing app info." +response=`curl -X PUT -H "Content-Length: 0" -L "http://fir.im/api/v2/app/$fir_app_id?token=$fir_token&version=$bundleVersion&versionShort=$bundleShortVersion" -v` +realShort=`ruby -e "require 'json'; iJson = JSON.parse '${response}'; puts iJson['short']"` #拼接完整的下载url,并在浏览器中打开 pulish_url=$fir_domain/$realShort From 42eb41ba9e8a5fa47b3845b1c93c4b61b8fb3ece Mon Sep 17 00:00:00 2001 From: d2eam Date: Tue, 14 Oct 2014 19:13:38 +0800 Subject: [PATCH 3/7] =?UTF-8?q?ipa-build=E5=A2=9E=E5=8A=A0=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=8F=82=E6=95=B0=EF=BC=8C=E8=BE=93=E5=87=BA=E5=8C=85?= =?UTF-8?q?=E5=90=8D=E4=BD=BF=E7=94=A8bundleDisplayName=EF=BC=9B=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0lib-build=E7=94=9F=E6=88=90=E9=9D=99=E6=80=81=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ipa-build | 31 +++++++-- lib-build | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 222 insertions(+), 6 deletions(-) create mode 100755 lib-build diff --git a/ipa-build b/ipa-build index 42ba763..d6e1178 100755 --- a/ipa-build +++ b/ipa-build @@ -4,7 +4,7 @@ # 功能:编译xcode项目并打ipa包 # 使用说明: # 编译project -# ipa-build [-c ] [-o ] [-t ] [-n] +# ipa-build [-c ] [-o ] [-t ] [-n] [-p ] # 编译workspace # ipa-build -w -s [-c ] [-n] # @@ -14,6 +14,7 @@ # -w 编译workspace # -s NAME 对应workspace下需要编译的scheme # -n 编译前是否先clean工程 +# -p 平台标识符 # 作者:ccf # E-mail:ccf.developer@gmail.com # 创建日期:2012/09/24 @@ -50,14 +51,29 @@ project_path=$(pwd) #编译的configuration,默认为Release build_config=Release -param_pattern=":nc:o:t:ws:" +param_pattern=":p:nc:o:t:ws:" OPTIND=2 while getopts $param_pattern optname do - case "$optname" in + case "$optname" in "n") should_clean=y ;; + "p") + tmp_optind=$OPTIND + tmp_optname=$optname + tmp_optarg=$OPTARG + + OPTIND=$OPTIND-1 + if getopts $param_pattern optname ;then + echo "Error argument value for option $tmp_optname" + exit 2 + fi + OPTIND=$tmp_optind + + platform_id=$tmp_optarg + + ;; "c") tmp_optind=$OPTIND tmp_optname=$optname @@ -84,8 +100,11 @@ while getopts $param_pattern optname fi OPTIND=$tmp_optind + cd $tmp_optarg output_path=$(pwd) + cd ${project_path} + if [ ! -d $output_path ];then echo "Error!The value of option o must be an exist directory." exit 2 @@ -171,7 +190,6 @@ if [ "$should_clean" = "y" ];then xcodebuild clean fi - #组合编译命令 build_cmd='xcodebuild' @@ -220,9 +238,10 @@ app_infoplist_path=${build_path}/${appdirname}/${appname}/Info.plist bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${app_infoplist_path}) #取build值 bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" ${app_infoplist_path}) - +#取displayName +displayName=$(/usr/libexec/PlistBuddy -c "print CFBundleDisplayName" ${app_infoplist_path}) #IPA名称 -ipa_name="${target_name}_${bundleShortVersion}_${build_config}${bundleVersion}_$(date +"%Y%m%d")" +ipa_name="${displayName}_${platform_id}_${bundleShortVersion}_${build_config}_${bundleVersion}_$(date +"%Y%m%d")" echo $ipa_name #xcrun打包 diff --git a/lib-build b/lib-build new file mode 100755 index 0000000..2ae9312 --- /dev/null +++ b/lib-build @@ -0,0 +1,197 @@ +#!/bin/bash + +#-------------------------------------------- +# 功能:编译static lib xcode项目 +# 使用说明: +# 编译project +# lib-build [-c ] [-o ] [-t ] [-n] +# 编译workspace +# lib-build -w -s [-c ] [-n] +# +# 参数说明:-c NAME 工程的configuration,默认为Release。 +# -o PATH 生成的lib文件输出的文件夹(必须为已存在的文件路径)默认为工程根路径下的”build/lib-build“文件夹中 +# -t NAME 需要编译的target的名称 +# -w 编译workspace +# -s NAME 对应workspace下需要编译的scheme +# -n 编译前是否先clean工程 +# 作者:zeb +# E-mail:zebbey@gmail.com +# 创建日期:2014/10/14 + + +if [ $# -lt 1 ];then + echo "Error! Should enter the root directory of xcode project after the lib-build command." + exit 2 +fi + +if [ ! -d $1 ];then + echo "Error! The first param must be a directory." + exit 2 +fi + +#工程绝对路径 +cd $1 +project_path=$(pwd) + +#编译的configuration,默认为Release +build_config=Release + +param_pattern=":nc:o:t:ws:" +OPTIND=2 +while getopts $param_pattern optname + do + case "$optname" in + "n") + should_clean=y + ;; + "c") + tmp_optind=$OPTIND + tmp_optname=$optname + tmp_optarg=$OPTARG + OPTIND=$OPTIND-1 + if getopts $param_pattern optname ;then + echo "Error argument value for option $tmp_optname" + exit 2 + fi + OPTIND=$tmp_optind + + build_config=$tmp_optarg + + ;; + "o") + tmp_optind=$OPTIND + tmp_optname=$optname + tmp_optarg=$OPTARG + + OPTIND=$OPTIND-1 + if getopts $param_pattern optname ;then + echo "Error argument value for option $tmp_optname" + exit 2 + fi + OPTIND=$tmp_optind + + cd $tmp_optarg + output_path=$(pwd) + if [ ! -d $output_path ];then + echo "Error!The value of option o must be an exist directory." + exit 2 + fi + + ;; + "w") + workspace_name='*.xcworkspace' + ls $project_path/$workspace_name &>/dev/null + rtnValue=$? + if [ $rtnValue = 0 ];then + build_workspace=$(echo $(basename $project_path/$workspace_name)) + else + echo "Error!Current path is not a xcode workspace.Please check, or do not use -w option." + exit 2 + fi + + ;; + "s") + tmp_optind=$OPTIND + tmp_optname=$optname + tmp_optarg=$OPTARG + + OPTIND=$OPTIND-1 + if getopts $param_pattern optname ;then + echo "Error argument value for option $tmp_optname" + exit 2 + fi + OPTIND=$tmp_optind + + build_scheme=$tmp_optarg + + ;; + "t") + tmp_optind=$OPTIND + tmp_optname=$optname + tmp_optarg=$OPTARG + + OPTIND=$OPTIND-1 + if getopts $param_pattern optname ;then + echo "Error argument value for option $tmp_optname" + exit 2 + fi + OPTIND=$tmp_optind + + build_target=$tmp_optarg + + ;; + + + "?") + echo "Error! Unknown option $OPTARG" + exit 2 + ;; + ":") + echo "Error! No argument value for option $OPTARG" + exit 2 + ;; + *) + # Should not occur + echo "Error! Unknown error while processing options" + exit 2 + ;; + esac + done + + +#build文件夹路径 +build_path=${project_path}/build +#生成的app文件目录 +appdirname=Release-iphoneos +if [ $build_config = Debug ];then + appdirname=Debug-iphoneos +fi +if [ $build_config = Distribute ];then + appdirname=Distribute-iphoneos +fi +#编译后文件路径(仅当编译workspace时才会用到) +compiled_path=${build_path}/${appdirname} + +#是否clean +if [ "$should_clean" = "y" ];then + xcodebuild clean +fi + + +#组合编译命令 +build_cmd='xcodebuild' + +if [ "$build_workspace" != "" ];then + #编译workspace + if [ "$build_scheme" = "" ];then + echo "Error! Must provide a scheme by -s option together when using -w option to compile a workspace." + exit 2 + fi + + build_cmd=${build_cmd}' -workspace '${build_workspace}' -scheme '${build_scheme}' -configuration '${build_config}' CONFIGURATION_BUILD_DIR='${compiled_path}' ONLY_ACTIVE_ARCH=NO' + + else + #编译project + build_cmd=${build_cmd}' -configuration '${build_config} + + if [ "$build_target" != "" ];then + build_cmd=${build_cmd}' -target '${build_target} + fi + +fi + + +#编译工程 +cd $project_path +$build_cmd || exit + +#进入build路径 +cd $build_path + +libname=$(basename ./${appdirname}/*.a) + +echo ${build_path} +if [ "$output_path" != "" ];then + cp ${build_path}/${appdirname}/${libname} $output_path/ + echo "Copy lib file successfully to the path $output_path" +fi From 0e01f8c17492bc5e2290cc597c58b775898ee8fb Mon Sep 17 00:00:00 2001 From: zeb Date: Tue, 14 Oct 2014 19:18:28 +0800 Subject: [PATCH 4/7] =?UTF-8?q?-o=E5=8F=82=E6=95=B0=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=BA=86=E7=9B=AE=E5=BD=95=E4=BB=A5=E5=90=8E=EF=BC=8C=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=86=8D=E5=88=87=E6=8D=A2=E5=9B=9E=E5=8E=BB=EF=BC=8C?= =?UTF-8?q?=E5=90=A6=E5=88=99-n=E5=8F=82=E6=95=B0=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib-build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib-build b/lib-build index 2ae9312..3d44eff 100755 --- a/lib-build +++ b/lib-build @@ -72,6 +72,8 @@ while getopts $param_pattern optname cd $tmp_optarg output_path=$(pwd) + cd ${project_path} + if [ ! -d $output_path ];then echo "Error!The value of option o must be an exist directory." exit 2 From 8c66b1022ce3e78566aec59955b36270dcd25f1e Mon Sep 17 00:00:00 2001 From: zeb Date: Thu, 16 Oct 2014 16:52:36 +0800 Subject: [PATCH 5/7] clean parameter --- ipa-build | 6 +++--- lib-build | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ipa-build b/ipa-build index d6e1178..a96516a 100755 --- a/ipa-build +++ b/ipa-build @@ -187,7 +187,7 @@ compiled_path=${build_path}/${appdirname} #是否clean if [ "$should_clean" = "y" ];then - xcodebuild clean + xcodebuild clean -configuration ${build_config} fi #组合编译命令 @@ -202,12 +202,12 @@ if [ "$build_workspace" != "" ];then build_cmd=${build_cmd}' -workspace '${build_workspace}' -scheme '${build_scheme}' -configuration '${build_config}' CONFIGURATION_BUILD_DIR='${compiled_path}' ONLY_ACTIVE_ARCH=NO' - else +else #编译project build_cmd=${build_cmd}' -configuration '${build_config} if [ "$build_target" != "" ];then - build_cmd=${build_cmd}' -target '${build_target} + build_cmd=${build_cmd}' -target '${build_target} fi fi diff --git a/lib-build b/lib-build index 3d44eff..5a9701a 100755 --- a/lib-build +++ b/lib-build @@ -73,7 +73,7 @@ while getopts $param_pattern optname cd $tmp_optarg output_path=$(pwd) cd ${project_path} - + if [ ! -d $output_path ];then echo "Error!The value of option o must be an exist directory." exit 2 @@ -156,7 +156,7 @@ compiled_path=${build_path}/${appdirname} #是否clean if [ "$should_clean" = "y" ];then - xcodebuild clean + xcodebuild clean -configuration ${build_config} fi @@ -172,7 +172,7 @@ if [ "$build_workspace" != "" ];then build_cmd=${build_cmd}' -workspace '${build_workspace}' -scheme '${build_scheme}' -configuration '${build_config}' CONFIGURATION_BUILD_DIR='${compiled_path}' ONLY_ACTIVE_ARCH=NO' - else +else #编译project build_cmd=${build_cmd}' -configuration '${build_config} From bfb0a10beb76020a76044c238b5b193956d2d5bd Mon Sep 17 00:00:00 2001 From: Carl Chen Date: Fri, 3 Feb 2017 18:58:28 +0800 Subject: [PATCH 6/7] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d2e738..13ff565 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ +Note +===== + +Highly suggest you use [**fastlane**(https://github.com/fastlane/fastlane)](https://github.com/fastlane/fastlane) instead of this project. + Introduce -=========== +====== ---- This repository contains a series of useful shell scripts which can help you to work effectively when programming for iOS platform. From e994e43243d3c7edb16c40db7d71d8adde5781cb Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 22 Mar 2017 14:22:10 +0800 Subject: [PATCH 7/7] deprecated ipa-publish-fir, and update Readme --- README.md | 11 +++++++---- ipa-publish-fir | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 13ff565..2e6308f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ + Note ===== -Highly suggest you use [**fastlane**(https://github.com/fastlane/fastlane)](https://github.com/fastlane/fastlane) instead of this project. +Highly suggest you use [**fastlane**](https://github.com/fastlane/fastlane) instead of this project. + +If you want to publish ipa to fir, use official project [**fir-cli**](https://github.com/FIRHQ/fir-cli) instead of this project. Script ipa-publish-fir is deprecated. Introduce ====== @@ -55,11 +58,11 @@ This ipa-build script is created to compile the xcode project and package the pr -w build xcode workspace -s NAME the schemal to be used for compiling -n clean the project before compling - + ####Example: ***build project*** - +​ If you have an iOS project in the path ~/iphone, and the ipa-build script is put in the path ~/xcode-shell.You want to build this project with 'Release' configuration.Just using script like this: cd ~/iphone @@ -76,7 +79,7 @@ If ~/iphone is a xcode workspace and the scheme used for compile named 'test'.Th You can also assign a specific configuration by using -c option. - + Note:If script executed successfully,an ipa file is created in the path: /build/ipa-build. ##2.compile project used CocoaPods diff --git a/ipa-publish-fir b/ipa-publish-fir index 3e8b91a..2206cde 100755 --- a/ipa-publish-fir +++ b/ipa-publish-fir @@ -27,18 +27,26 @@ # 修改人:Shannon Chou # 修改内容:在原ipa-publish 的基础上改为ipa-publish-fir,用于将app 发布到fir.im上测试 #-------------------------------------------- +# 修改日期:2017/03/22 +# 修改人:Shannon Chou +# 修改内容:修改配置部分, 该脚本已废弃,建议使用fir 官方cli 工具 +#-------------------------------------------- + + + + + #须配置内容 start -#以下是邮箱的相关设置,jiecao.fm 提供了一个可以直接使用的邮箱账号,请不要去更改邮箱密码,以便他人使用 -#更改收件人就可直接使用 +#以下是邮箱的相关设置 #收件人,多个收件人以空格分隔 -email_reciver="zhoujun@jiecao.fm shannonchou@sina.com" +email_reciver="" #发送者邮箱 -email_sender=xcodeshell@jiecao.fm +email_sender= #邮箱用户名 -email_username=xcodeshell@jiecao.fm +email_username= #邮箱密码 -email_password=jiecao.fm1 +email_password= #smtp服务器地址 email_smtphost=smtp.exmail.qq.com