Class: Shell_Command
- Inherits:
-
Object
- Object
- Shell_Command
- Includes:
- Uki_config::Mixin
- Defined in:
- lib/cocoapods-uki-packager/shell.rb
Defined Under Namespace
Modules: Mixin
Class Attribute Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#export ⇒ Object
暂时先不copy到跟目录, 防止Git提交代码时提交上去 需安装Fir 不太友好 安装命令 sudo gem install fir-cli.
- #export_xcode_env ⇒ Object
- #send_notifi ⇒ Object
Methods included from Uki_config::Mixin
Class Attribute Details
.instance ⇒ Object
289 290 291 |
# File 'lib/cocoapods-uki-packager/shell.rb', line 289 def self.instance @instance ||= new end |
Instance Method Details
#build ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cocoapods-uki-packager/shell.rb', line 48 def build puts("********************************************************* 开始编译") if uki_config.verbose? puts("xcodebuild build -workspace #{uki_config.workspace} -scheme #{uki_config.scheme} -destination generic/platform=iOS -configuration #{uki_config.configuration} DEBUG_INFORMATION_FORMAT=#{uki_config.dsym_config} DWARF_DSYM_FOLDER_PATH=#{uki_config.dsym_path}") end log = %x{ xcodebuild build -workspace #{uki_config.workspace} -scheme #{uki_config.scheme} -destination generic/platform=iOS -configuration #{uki_config.configuration} DEBUG_INFORMATION_FORMAT=#{uki_config.dsym_config} DWARF_DSYM_FOLDER_PATH=#{uki_config.dsym_path} } if log[/BUILD SUCCEEDED/] puts("********************************************************* 编译完成") # 直接开始导出 self.export elsif puts("********************************************************* 编译失败") exit end end |
#export ⇒ Object
暂时先不copy到跟目录, 防止Git提交代码时提交上去需安装Fir 不太友好安装命令 sudo gem install fir-cli
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/cocoapods-uki-packager/shell.rb', line 73 def export unless uki_config.build_exe_path puts "未找到目标文件目录" exit end puts %x{echo "********************************************************* 开始导出ipa"} log = %x{ product_path=#{uki_config.build_exe_path} if [[ $product_path == "" ]]; then echo "===no path input===" product_path=`dirname $0` fi echo -e “=====path=$product_path =====“ cd $product_path fir_log="fir auto release" APP=$(find $product_path -type d | grep ".app$" | head -n 1) APP=${APP%.*} echo -e “=====APP=$APP =====“ rm -rf "$APP.ipa"; rm -rf ./Payload; mkdir Payload; cp -rf "$APP.app" ./Payload; zip -r -q "$APP.ipa" ./Payload; rm -rf ./Payload; # echo "===生成ipa开始上传 ===" #计时 SECONDS=0 # fir_token="207c7aad886da8009a73486d5154a7a6" # fir publish "$APP.ipa" -T $fir_token -c "$fir_log" -R apiKey="2b73b132408ae0145c5e7cb871c37036" uKey="3bd6eb4f50db762b0d83fabb6692713f" curl -F "file=@$APP.ipa" -F "uKey=$uKey" -F "_api_key=$apiKey" -F "updateDescription=$log" https://www.pgyer.com/apiv1/app/upload size=$(ls -l $APP.ipa | awk '{ print $5 }') sizeM=`echo "scale=2; ${size}/1024.0/1024" | bc` #sizeM="$((${size}/1000.0)) echo -e "包体积=${sizeM}m\n" notification="Did uploaded to fir caost time:${SECONDS}s" echo "===$notification===%" osascript -e 'display notification "size:'$sizeM'm\ncaost:'$SECONDS's" with title "Uploaded to fir!" sound name "default" ' echo "upload_time=${SECONDS}" } ipa_size = log[/包体积.*$/].split('=').last # url = log[/http:.*$/].to_s url = if uki_config.workspace == "miaohong.xcworkspace" "https://www.pgyer.com/K70I" else "https://www.pgyer.com/uGp4" end array = log.split('%') uki_config.upload_time = array.last.split("=").last.to_i uki_config.build_time = Time.now.to_i - uki_config.build_time - uki_config.upload_time uki_config.fir_url = url uki_config.ipa_size = ipa_size unless !url.empty? puts("导出失败") exit end puts("恭喜打包完成") if uki_config.verbose? puts(log) end send_notifi end |
#export_xcode_env ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cocoapods-uki-packager/shell.rb', line 13 def export_xcode_env puts("********************************************************* 开始导出Xcode环境变量") log = %x{ rootPath=`pwd` fireName="xcode_env.json" full_path="${rootPath}/${fireName}" if [ -f "$full_path" ] then echo "存在xcode_env.json" else echo "不存在xcode_env.json 创建一个" touch ${full_path} fi if [ -f "$full_path" ] then echo `xcodebuild -showBuildSettings -json` > "$full_path" fi } if !File.exist?(uki_config.xcode_env_path) puts("当前目录未查找到xcode_env.json文件, 请检查执行目录") exit end json_from_file = File.read(uki_config.xcode_env_path) uki_config.xcode_envs = JSON.parse(json_from_file).first if uki_config.verbose? puts(log) end end |
#send_notifi ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/cocoapods-uki-packager/shell.rb', line 165 def send_notifi branch = %x{ if branch=$(git symbolic-ref --short -q HEAD) then echo $branch else echo "未知分支" fi } hostname = Socket.gethostname project_name = uki_config.group_name project_env = uki_config.release ? "Release": "Debug" project_dsym = uki_config.dsym ? "已上传": "无符号表" = { "msg_type": "interactive", "card": { "elements": [ { "fields": [ { "is_short": true, "text": { "content": "**打包分支**\n#{branch}", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**打包环境**\n#{project_env}", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**打包机器**\n#{hostname}", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**dsym**\n#{project_dsym}", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**App版本**\n#{uki_config.app_version}.#{uki_config.build_version}", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**包体积**\n#{uki_config.ipa_size}", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**编译耗时**\n#{uki_config.build_time}s", "tag": "lark_md" } }, { "is_short": true, "text": { "content": "**上传耗时**\n#{uki_config.upload_time}s", "tag": "lark_md" } } ], "tag": "div" }, { "tag": "hr" }, { "tag": "action", "actions": [ { "tag": "button", "text": { "tag": "lark_md", "content": "点击下载" }, "type": "default", "url": "#{uki_config.fir_url}" } ] } ], "header": { "template": "green", "title": { "content": "#{project_name}", "tag": "plain_text" } } } } # https://open.feishu.cn/open-apis/bot/v2/hook/68c47d38-fc65-4cc5-a386-885a1fbff11b 测试机器人 # https://open.feishu.cn/open-apis/bot/v2/hook/68c47d38-fc65-4cc5-a386-885a1fbff11b 打包群机器人 log = %x{ curl -X POST -H "Content-Type: application/json" -d '#{message.to_json}' "https://open.feishu.cn/open-apis/bot/v2/hook/68c47d38-fc65-4cc5-a386-885a1fbff11b" } if uki_config.verbose? puts(log) end exit end |