验证中...
appcenter-post-build.sh
原始数据 复制代码
#!/usr/bin/env bash
# 使用前应先在App Center的编译配置中添加环境变量APP_NAME和FIR_API_TOKEN;
# 此文件应放在app模块中,与build.gradle文件在一起;
# 添加文件后若没有生效,可以到App Center中检查编译配置是否检测到此脚本,如果检测到,尝试将编译配置保存一下。
# 参考:Visual Studio App Center Build Scripts - https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/
# 参考:fir.im documents - https://fir.im/docs/description
# name即app_name,取自manifest中application的android:label字段,但因为此字段一般都指向@string/app_name,所以不能从manifest中直接获取
name="$APP_NAME"
# filename即生成的apk文件的名字,命名规则:模块[-productFlavor][-release|debug].apk
filename="app-release.apk"
type="android"
bundle_id=`sed -n -e 's#.*applicationId \"\(.*\)\"#\1# p' build.gradle`
version=`sed -n -e 's#.*versionName \"\(.*\)\"#\1# p' build.gradle`
build=`sed -n -e 's#.*versionCode *\(.*\)#\1# p' build.gradle`
changelog=`git log --pretty=format:"%s" -n1`
upload_info=`curl -X "POST" "http://api.fir.im/apps" -H "Content-Type: application/json" -d "{\"type\":\"$type\", \"bundle_id\":\"$bundle_id\", \"api_token\":\"$FIR_API_TOKEN\"}"`
key=`echo $upload_info | sed -e 's#.*binary.*key\":\"\(.*\)\",\"token\":\"\(.*\)\",\"upload_url\":\"\(.*\)\",\"custom_headers.*#\1#'`
token=`echo $upload_info | sed -e 's#.*binary.*key\":\"\(.*\)\",\"token\":\"\(.*\)\",\"upload_url\":\"\(.*\)\",\"custom_headers.*#\2#'`
upload_url=`echo $upload_info | sed -e 's#.*binary.*key\":\"\(.*\)\",\"token\":\"\(.*\)\",\"upload_url\":\"\(.*\)\",\"custom_headers.*#\3#'`
curl -F "key=$key" \
-F "token=$token" \
-F "file=@$APPCENTER_OUTPUT_DIRECTORY/$filename" \
-F "x:name=$name" \
-F "x:version=$version" \
-F "x:build=$build" \
-F "x:release_type=Adhoc" \
-F "x:changelog=$changelog" \
$upload_url

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助