From a07c78d5e4a1f855c893e6552d237f8c29d7c806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=99=E6=BC=A0=E4=B9=8B=E5=AD=90?= <7850715+maboloshi@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:03:43 +0800 Subject: [PATCH] =?UTF-8?q?GA=EF=BC=9A=E6=9B=B4=E6=96=B0=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=89=88=E8=AF=8D=E5=BA=93=E7=89=88=E6=9C=AC=E5=8F=B7=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=BA=90=E8=AF=8D=E5=BA=93?= =?UTF-8?q?`locals.js`=E7=9A=84=E6=96=87=E4=BB=B6=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/locals(greasyfork).js_update.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/locals(greasyfork).js_update.yaml b/.github/workflows/locals(greasyfork).js_update.yaml index a137fd50d..57678c4fe 100644 --- a/.github/workflows/locals(greasyfork).js_update.yaml +++ b/.github/workflows/locals(greasyfork).js_update.yaml @@ -26,8 +26,14 @@ jobs: run: | # 获得最近以`main.user.js Update to version`开头的提交的引用 ref=$(git log --grep="^main.user.js Update to version" -n 1 --pretty=format:"%H") + + # 获取该提交中`locals.js`的文件时间, 并设置环境变量 + locals_js_time=$(git log -1 --format=%at $ref -- locals.js) + echo "locals_js_time=$locals_js_time" >> $GITHUB_ENV + # 从该提交中提取文件`locals.js`并覆写到本地文件`locals(greasyfork).js` git show $ref:locals.js > "locals(greasyfork).js" + git diff --quiet --exit-code "locals(greasyfork).js" || \ echo "LOCALS_JS_IS_CHANGED=true" >> $GITHUB_ENV @@ -35,8 +41,10 @@ jobs: if: | ${{ env.LOCALS_JS_IS_CHANGED == 'true' }} run: | + # 使用`locals.js`的文件日期为词库版本号 + locals_js_date=$(TZ='Asia/Shanghai' date -d "@${{ env.locals_js_time }}" +'%Y-%m-%d') sed -i -E "s/(@version\s*[0-9]+\.[0-9]+\.[0-9]+)(-[0-9]{4}-[0-9]{2}-[0-9]{2})?/\ - \1-$(TZ='Asia/Shanghai' date +'%Y-%m-%d')/" "main(greasyfork).user.js" + \1-$locals_js_date/" "main(greasyfork).user.js" git diff --quiet --exit-code "main(greasyfork).user.js" || \ echo "MAIN_USER_JS_IS_CHANGED=true" >> $GITHUB_ENV