mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
ci: update cronet.sh
This commit is contained in:
parent
6cd211e1fa
commit
3cc17a39b4
38
.github/scripts/cronet.sh
vendored
38
.github/scripts/cronet.sh
vendored
@ -11,32 +11,45 @@ max_offset=$2
|
||||
|
||||
offset=0
|
||||
|
||||
function fetchExitVersion() {
|
||||
function fetch_version() {
|
||||
# 获取最新cronet版本
|
||||
echo "fetch $branch release info from https://chromiumdash.appspot.com ..."
|
||||
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
|
||||
checkVersionExit
|
||||
check_version_exit
|
||||
}
|
||||
function checkVersionExit() {
|
||||
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
|
||||
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"
|
||||
fetchExitVersion
|
||||
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
|
||||
fi
|
||||
if [[ $(printf '%s\n' "$1" "$2" | sort -V | head -n1) == $remote_version ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# 添加变量到github env
|
||||
function writeVariableToGithubEnv() {
|
||||
function write_github_env_variable() {
|
||||
echo "$1=$2" >> $GITHUB_ENV
|
||||
}
|
||||
|
||||
@ -46,17 +59,18 @@ path=$GITHUB_WORKSPACE/gradle.properties
|
||||
current_cronet_version=`cat $path | grep CronetVersion | sed s/CronetVersion=//`
|
||||
echo "current_cronet_version: $current_cronet_version"
|
||||
|
||||
fetchExitVersion
|
||||
echo "fetch $branch release info from https://chromiumdash.appspot.com ..."
|
||||
fetch_version
|
||||
|
||||
if [[ $current_cronet_version < $lastest_cronet_version ]];then
|
||||
if version_compare $current_cronet_version $lastest_cronet_version; then
|
||||
# 更新gradle.properties
|
||||
sed -i s/CronetVersion=.*/CronetVersion=$lastest_cronet_version/ $path
|
||||
sed -i s/CronetMainVersion=.*/CronetMainVersion=$lastest_cronet_main_version/ $path
|
||||
# 添加更新日志
|
||||
sed "15a* 更新cronet: $lastest_cronet_version" -i $GITHUB_WORKSPACE/app/src/main/assets/updateLog.md
|
||||
# 生成pull request信息
|
||||
writeVariableToGithubEnv PR_TITLE "Bump cronet from $current_cronet_version to $lastest_cronet_version"
|
||||
writeVariableToGithubEnv PR_BODY "Changes in the [Git log](https://chromium.googlesource.com/chromium/src/+log/$current_cronet_version..$lastest_cronet_version)"
|
||||
write_github_env_variable PR_TITLE "Bump cronet from $current_cronet_version to $lastest_cronet_version"
|
||||
write_github_env_variable PR_BODY "Changes in the [Git log](https://chromium.googlesource.com/chromium/src/+log/$current_cronet_version..$lastest_cronet_version)"
|
||||
# 生成cronet flag
|
||||
writeVariableToGithubEnv cronet ok
|
||||
write_github_env_variable cronet ok
|
||||
fi
|
Loading…
Reference in New Issue
Block a user