[skip ci] update workflows

This commit is contained in:
Xwite 2023-03-09 08:24:19 +08:00
parent a6c9b05d52
commit a15a2119d2
3 changed files with 31 additions and 19 deletions

View File

@ -1,14 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "fetch release info from https://chromiumdash.appspot.com ..." branch=$1
[ -z $1 ] && branch=Stable
branch="Stable" [ -z $GITHUB_ENV ] && echo "Error: Unexpected github workflow environment" && exit
# 获取最新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=0" | jq .[0].version -r` lastest_cronet_version=`curl -s "https://chromiumdash.appspot.com/fetch_releases?channel=$branch&platform=Android&num=1&offset=0" | jq .[0].version -r`
echo "lastest_cronet_version: $lastest_cronet_version" echo "lastest_cronet_version: $lastest_cronet_version"
#lastest_cronet_version=100.0.4845.0 #lastest_cronet_version=100.0.4845.0
lastest_cronet_main_version=${lastest_cronet_version%%\.*}.0.0.0 lastest_cronet_main_version=${lastest_cronet_version%%\.*}.0.0.0
# 检查版本是否存在
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)
@ -17,18 +19,25 @@ function checkVersionExit() {
exit exit
fi fi
} }
# 添加变量到github env
function writeVariableToGithubEnv() {
echo "$1=$2" >> $GITHUB_ENV
}
# 获取本地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"
if [[ $current_cronet_version < $lastest_cronet_version ]];then if [[ $current_cronet_version < $lastest_cronet_version ]];then
checkVersionExit checkVersionExit
# 更新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
# 添加更新日志
sed "15a* 更新cronet: $lastest_cronet_version" -i $GITHUB_WORKSPACE/app/src/main/assets/updateLog.md sed "15a* 更新cronet: $lastest_cronet_version" -i $GITHUB_WORKSPACE/app/src/main/assets/updateLog.md
echo "start download latest cronet" # 生成pull request信息
chmod +x gradlew writeVariableToGithubEnv PR_TITLE "Bump cronet from $current_cronet_version to $lastest_cronet_version"
./gradlew app:downloadCronet writeVariableToGithubEnv 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
fi fi

View File

@ -11,17 +11,18 @@ jobs:
if: ${{ github.repository == 'gedoor/legado' }} if: ${{ github.repository == 'gedoor/legado' }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
- name: Check Cronet Updates - name: Check Cronet Updates
run: source .github/scripts/cronet.sh
- name: Download Cronet
uses: gradle/gradle-build-action@v2
if: ${{ env.cronet == 'ok' }}
run: | run: |
echo "获取cronet最新版本" chmod +x gradlew
source .github/scripts/cronet.sh ./gradlew app:downloadCronet
echo "PR_TITLE=Bump cronet from $current_cronet_version to $lastest_cronet_version " >> $GITHUB_ENV
echo "PR_BODY=Changes in the [Git log](https://chromium.googlesource.com/chromium/src/+log/$current_cronet_version..$lastest_cronet_version)" >> $GITHUB_ENV
- name: Create Pull Request - name: Create Pull Request
if: ${{ env.cronet == 'ok' }}
uses: peter-evans/create-pull-request@v4 uses: peter-evans/create-pull-request@v4
continue-on-error: true continue-on-error: true
with: with:

View File

@ -585,16 +585,18 @@ class AnalyzeUrl(
/** /**
* 设置cookie 优先级 * 设置cookie 优先级
* urlOption临时cookie > 数据库cookie = okhttp CookieJar保存在内存中的cookie * urlOption临时cookie > 数据库cookie
*/ */
private fun setCookie() { private fun setCookie() {
val cookie = kotlin.run { val cookie = kotlin.run {
/* 每次调用getXX cookieJar已经保存过了
if (enabledCookieJar) { if (enabledCookieJar) {
val key = "${domain}_cookieJar" val key = "${domain}_cookieJar"
CacheManager.getFromMemory(key)?.let { CacheManager.getFromMemory(key)?.let {
return@run it return@run it
} }
} }
*/
CookieStore.getCookie(domain) CookieStore.getCookie(domain)
} }
if (cookie.isNotEmpty()) { if (cookie.isNotEmpty()) {
@ -608,7 +610,7 @@ class AnalyzeUrl(
} }
/** /**
* 保存cookie在访问结束时就保存,不等到下次访问 * 保存cookieJar中的cookie在访问结束时就保存,不等到下次访问
*/ */
private fun saveCookie() { private fun saveCookie() {
//书源启用保存cookie时 添加内存中的cookie到数据库 //书源启用保存cookie时 添加内存中的cookie到数据库