Skip to content

Commit

Permalink
GA:更新发布版词库版本号逻辑,使用源词库locals.js的文件日期
Browse files Browse the repository at this point in the history
  • Loading branch information
maboloshi committed Jul 12, 2024
1 parent f0042d5 commit a07c78d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/locals(greasyfork).js_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@ 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
- name: Update version in main(greasyfork).user.js
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
Expand Down

0 comments on commit a07c78d

Please sign in to comment.