Skip to content

Commit

Permalink
Update main.user.js_version_update.yaml
Browse files Browse the repository at this point in the history
Signed-off-by: 沙漠之子 <[email protected]>
  • Loading branch information
maboloshi authored Dec 15, 2023
1 parent 31009a9 commit 1d741db
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/main.user.js_version_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,22 @@ jobs:
run: |
# 最近提交是否存在tag
if [ ! "$(git tag --contains ${{ github.sha }})" ]; then
# 获得最近以`main.user.js Update to version`开头的提交的sha
# 获得最近以`main.user.js Update to version`开头的提交的sha和时间戳
release_commit_sha=$(git log --grep="^main.user.js Update to version" -n 1 --pretty=format:"%H")
git log -n 10 --pretty=oneline
git log --grep="^main.user.js Update to version" -n 1 --pretty=format:"%H"
# 对应的时间戳
release_commit_timestamp=$(git show -s --format=%ct $release_commit_sha)
git show -s --format=%ct $release_commit_sha
# 最近的tag的时间戳
# 最近的tag的sha和时间戳
latest_tag_commit_sha=$(git rev-list --tags --max-count=1)
git rev-list --tags --max-count=1
latest_tag_commit_timestamp=$(git show -s --format=%ct $latest_tag_commit_sha)
git show -s --format=%ct $latest_tag_commit_sha
echo "release_commit_sha=$release_commit_sha"
echo "release_commit_timestamp=$release_commit_timestamp"
echo "latest_tag_commit_sha=$latest_tag_commit_sha"
echo "latest_tag_commit_timestamp=$latest_tag_commit_timestamp"
if [ $release_commit_timestamp -gt $latest_tag_commit_timestamp ]; then
ref=$release_commit_sha
else
ref=$latest_tag_commit_sha
fi
git diff --quiet --exit-code $ref locals.js || {echo "LOCALS_JS_IS_CHANGED=true" && echo "LOCALS_JS_IS_CHANGED=true" >> $GITHUB_ENV}
git diff --quiet --exit-code $ref locals.js || \
echo "LOCALS_JS_IS_CHANGED=true" >> $GITHUB_ENV
fi
- name: Update version in main.user.js
Expand All @@ -52,7 +42,8 @@ jobs:
run: |
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.user.js
git diff --quiet --exit-code main.user.js || {echo "MAIN_USER_JS_IS_CHANGED=true" && echo "MAIN_USER_JS_IS_CHANGED=true" >> $GITHUB_ENV}
git diff --quiet --exit-code main.user.js || \
echo "MAIN_USER_JS_IS_CHANGED=true" >> $GITHUB_ENV}
- name: Commit and push main.user.js
if: ${{ env.LOCALS_JS_IS_CHANGED == 'true' &&
Expand Down

0 comments on commit 1d741db

Please sign in to comment.