Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,35 +1,54 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#分支Stable Dev Beta
|
||||||
branch=$1
|
branch=$1
|
||||||
|
#api 最大偏移
|
||||||
|
max_offset=$2
|
||||||
|
|
||||||
[ -z $1 ] && branch=Stable
|
[ -z $1 ] && branch=Stable
|
||||||
|
[ -z $2 ] && max_offset=3
|
||||||
[ -z $GITHUB_ENV ] && echo "Error: Unexpected github workflow environment" && exit
|
[ -z $GITHUB_ENV ] && echo "Error: Unexpected github workflow environment" && exit
|
||||||
|
|
||||||
# 获取最新cronet版本
|
offset=0
|
||||||
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=0" | jq .[0].version -r`
|
function fetchExitVersion() {
|
||||||
echo "lastest_cronet_version: $lastest_cronet_version"
|
# 获取最新cronet版本
|
||||||
#lastest_cronet_version=100.0.4845.0
|
echo "fetch $branch release info from https://chromiumdash.appspot.com ..."
|
||||||
lastest_cronet_main_version=${lastest_cronet_version%%\.*}.0.0.0
|
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
|
||||||
|
}
|
||||||
function checkVersionExit() {
|
function checkVersionExit() {
|
||||||
|
# 检查版本是否存在
|
||||||
local jar_url="https://storage.googleapis.com/chromium-cronet/android/$lastest_cronet_version/Release/cronet/cronet_api.jar"
|
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)
|
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"
|
echo "storage.googleapis.com return 404 for cronet $lastest_cronet_version"
|
||||||
exit
|
if [[ $max_offset > $offset ]]; then
|
||||||
|
offset=$(expr $offset + 1)
|
||||||
|
echo "retry with offset $offset"
|
||||||
|
fetchExitVersion
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# 添加变量到github env
|
# 添加变量到github env
|
||||||
function writeVariableToGithubEnv() {
|
function writeVariableToGithubEnv() {
|
||||||
echo "$1=$2" >> $GITHUB_ENV
|
echo "$1=$2" >> $GITHUB_ENV
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##########
|
||||||
# 获取本地cronet版本
|
# 获取本地cronet版本
|
||||||
path=$GITHUB_WORKSPACE/gradle.properties
|
path=$GITHUB_WORKSPACE/gradle.properties
|
||||||
current_cronet_version=`cat $path | grep CronetVersion | sed s/CronetVersion=//`
|
current_cronet_version=`cat $path | grep CronetVersion | sed s/CronetVersion=//`
|
||||||
echo "current_cronet_version: $current_cronet_version"
|
echo "current_cronet_version: $current_cronet_version"
|
||||||
|
|
||||||
|
fetchExitVersion
|
||||||
|
|
||||||
if [[ $current_cronet_version < $lastest_cronet_version ]];then
|
if [[ $current_cronet_version < $lastest_cronet_version ]];then
|
||||||
checkVersionExit
|
|
||||||
# 更新gradle.properties
|
# 更新gradle.properties
|
||||||
sed -i s/CronetVersion=.*/CronetVersion=$lastest_cronet_version/ $path
|
sed -i s/CronetVersion=.*/CronetVersion=$lastest_cronet_version/ $path
|
||||||
sed -i s/CronetMainVersion=.*/CronetMainVersion=$lastest_cronet_main_version/ $path
|
sed -i s/CronetMainVersion=.*/CronetMainVersion=$lastest_cronet_main_version/ $path
|
||||||
|
|||||||
@@ -151,13 +151,13 @@ object Backup {
|
|||||||
if (ZipUtils.zipFiles(paths, zipFilePath)) {
|
if (ZipUtils.zipFiles(paths, zipFilePath)) {
|
||||||
when {
|
when {
|
||||||
path.isNullOrBlank() -> {
|
path.isNullOrBlank() -> {
|
||||||
copyBackup(context.getExternalFilesDir(null)!!, zipFileName)
|
copyBackup(context.getExternalFilesDir(null)!!, "backup.zip")
|
||||||
}
|
}
|
||||||
path.isContentScheme() -> {
|
path.isContentScheme() -> {
|
||||||
copyBackup(context, Uri.parse(path), zipFileName)
|
copyBackup(context, Uri.parse(path), "backup.zip")
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
copyBackup(File(path), zipFileName)
|
copyBackup(File(path), "backup.zip")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppWebDav.backUpWebDav(zipFileName)
|
AppWebDav.backUpWebDav(zipFileName)
|
||||||
@@ -175,6 +175,7 @@ object Backup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
||||||
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc ->
|
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc ->
|
||||||
treeDoc.findFile(fileName)?.delete()
|
treeDoc.findFile(fileName)?.delete()
|
||||||
@@ -187,6 +188,7 @@ object Backup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
private fun copyBackup(rootFile: File, fileName: String) {
|
private fun copyBackup(rootFile: File, fileName: String) {
|
||||||
FileInputStream(File(zipFilePath)).use { inputS ->
|
FileInputStream(File(zipFilePath)).use { inputS ->
|
||||||
val file = FileUtils.createFileIfNotExist(rootFile, fileName)
|
val file = FileUtils.createFileIfNotExist(rootFile, fileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user