93 lines
3.4 KiB
Bash
93 lines
3.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
#分支Stable Dev Beta
|
|
branch=$1
|
|
#api 最大偏移
|
|
max_offset=$2
|
|
|
|
[ -z $1 ] && branch=Stable
|
|
[ -z $2 ] && max_offset=3
|
|
[ -z $GITHUB_ENV ] && echo "Error: Unexpected github workflow environment" && exit
|
|
|
|
offset=0
|
|
|
|
function fetch_version() {
|
|
# 获取最新cronet版本
|
|
lastest_cronet_version=`curl -s "https://chromiumdash.appspot.com/fetch_releases?channel=$branch&platform=Android&num=1&offset=$offset" | jq .[0].version -r`
|
|
echo "lastest_cronet_version: $lastest_cronet_version"
|
|
#lastest_cronet_version=100.0.4845.0
|
|
lastest_cronet_main_version=${lastest_cronet_version%%\.*}.0.0.0
|
|
check_version_exit
|
|
}
|
|
function check_version_exit() {
|
|
# 检查版本是否存在
|
|
local jar_url="https://storage.googleapis.com/chromium-cronet/android/$lastest_cronet_version/Release/cronet/cronet_api.jar"
|
|
statusCode=$(curl -s -I -w %{http_code} "$jar_url" -o /dev/null)
|
|
if [ $statusCode == "404" ]; then
|
|
echo "storage.googleapis.com return 404 for cronet $lastest_cronet_version"
|
|
if [[ $max_offset > $offset ]]; then
|
|
offset=$(expr $offset + 1)
|
|
echo "retry with offset $offset"
|
|
fetch_version
|
|
else
|
|
exit
|
|
fi
|
|
fi
|
|
}
|
|
function version_compare() {
|
|
# 版本号比较 本地版本小于远程版本时返回0
|
|
local local_version=$1
|
|
local remote_version=$2
|
|
if [[ $local_version == $remote_version ]]; then
|
|
return 1
|