Flutter Distributor是使用Dart寫的CI工具召廷,可用于打包和發(fā)布Flutter應(yīng)用咖耘。官方文檔
安裝
dart pub global activate flutter_distributor
用法
將 distribute_options.yaml
添加到項目根目錄,并設(shè)定ipa体捏、apk文件輸出路徑:
output: dist/
配置發(fā)布項
build_args
是 flutter build
命令所支持的參數(shù),可根據(jù)項目進(jìn)行修改。
env:
PGYER_API_KEY: 'your api key'
output: dist/
releases:
- name: dev
jobs:
# 構(gòu)建 apk 包并將其發(fā)布到 pgyer
- name: release-dev-android
package:
platform: android
target: apk
build_args:
target-platform: android-arm,android-arm64
dart-define:
APP_ENV: dev
publish_to: pgyer
# 構(gòu)建 ipa 包并將其發(fā)布到 pgyer
- name: release-dev-ios
package:
platform: ios
target: ipa
build_args:
export-options-plist: ios/ExportOptions.plist
dart-define:
APP_ENV: dev
publish_to: pgyer
發(fā)布應(yīng)用
# 安卓包
flutter_distributor release --name dev --jobs release-dev-android
# iOS包
flutter_distributor release --name dev --jobs release-dev-ios
# iOS及安卓包
flutter_distributor release --name dev
目前Flutter Distributor
還沒支持打完包后釘釘通知相應(yīng)測試人員窄做,所以可以自己添加腳本使用curl
來做,shell
腳本如下:
#!/bin/bash
check_results=`flutter_distributor --version`
if [[ $check_results =~ "0.1.8" ]]
then
echo "flutter_distributor version is 0.1.8, it seems not need to install flutter_distributor again."
else
echo "It is going to install flutter_distributor 0.1.8 version"
dart pub global activate flutter_distributor 0.1.8
fi
echo "請選擇打包方式 ? [ 1:安卓 2:iOS 3:iOS加安卓 4:安卓國內(nèi)v7及v8]"
read number
while ([[ $number != 1 ]] && [[ $number != 2 ]] && [[ $number != 3 ]] && [[ $number != 4 ]])
do
echo "請選擇打包方式 ? [ 1:安卓 2:iOS 3:iOS加安卓 4:安卓國內(nèi)v7及v8]"
read number
done
url="https://oapi.dingtalk.com/robot/send?access_token=xxx"
readonly url;
echo $url
downUrlForiOS="https://www.pgyer.com/xxx"
readonly downUrlForiOS
echo $downUrlForiOS
downUrlForAndroid="https://www.pgyer.com/xxx"
readonly downUrlForAndroid
echo $downUrlForAndroid
#at
phones='"xxx","xxx"'
readonly phones;
echo $phones
#測試描述
desc='請測試'
echo $number
if [ $number -eq 1 ];then
echo "安卓開始打包"
# 安卓包
flutter_distributor release --name dev --jobs release-dev-android
# 上傳蒲公英
curl -H 'Content-Type: application/json' -X POST -d '{
"at": {
"atMobiles":['"$phones"'],
"isAtAll": false
},
"text": {
"content":"安卓新包:'$downUrlForAndroid'慰技,'$desc'"
},
"msgtype":"text"
}' $url
echo -e "\n upload android success \n"
elif [ $number -eq 2 ]; then
echo "iOS開始打包"
# iOS包
flutter_distributor release --name dev --jobs release-dev-ios
# 上傳蒲公英
curl -H 'Content-Type: application/json' -X POST -d '{
"at": {
"atMobiles":['"$phones"'],
"isAtAll": false
},
"text": {
"content":"iOS新包:'$downUrlForiOS'椭盏,'$desc'"
},
"msgtype":"text"
}' $url
echo -e "\n upload iOS success \n"
elif [ $number -eq 3 ]; then
echo "安卓及iOS開始打包"
# iOS&安卓包
flutter_distributor release --name dev
# 上傳蒲公英
curl -H 'Content-Type: application/json' -X POST -d '{
"at": {
"atMobiles":['"$phones"'],
"isAtAll": false
},
"text": {
"content":"安卓新包:'$downUrlForAndroid',\n iOS新包: '$downUrlForiOS','$desc'"
},
"msgtype":"text"
}' $url
echo -e "\n upload iOS吻商、android success \n"
fi
exit