main.user.js version update #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main.user.js version update | |
on: | |
schedule: | |
- cron: "0 16 * * 0" | |
workflow_dispatch: | |
jobs: | |
update_version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check if commit is ahead of latest tag | |
run: | | |
LATEST_TAG_COMMIT_SHA=$(git rev-list --tags --max-count=1) | |
LAST_COMMIT_SHA=${{ github.sha }} | |
if [ "$LAST_COMMIT_SHA" != "$LATEST_TAG_COMMIT_SHA" ]; then | |
echo "AHEAD=true" >> $GITHUB_ENV | |
else | |
echo "AHEAD=false" >> $GITHUB_ENV | |
fi | |
- name: Get last commit message | |
run: | | |
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") | |
echo "LAST_COMMIT_MESSAGE=$LAST_COMMIT_MESSAGE" >> $GITHUB_ENV | |
- name: Update version in main.user.js | |
if: | | |
${{ env.AHEAD == 'true' }} && | |
${{ !startsWith(env.LAST_COMMIT_MESSAGE, 'main.user.js Update to version') }} | |
run: | | |
sed -i "s/@version\s*[^\\s]*/@version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')/" main.user.js | |
git diff --quiet --exit-code main.user.js || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV | |
git diff --exit-code main.user.js | |
echo "env.CHANGES_DETECTED=" ${{ env.CHANGES_DETECTED }} | |
cat main.user.js | |
- name: Commit and push main.user.js | |
if: ${{ env.AHEAD == 'true' && env.CHANGES_DETECTED == 'true' }} | |
run: | | |
bash script/ci_commit_with_signature.sh \ | |
${{ secrets.CI_GITHUB_TOKEN }} \ | |
${{ github.repository }} \ | |
${{ github.ref_name }} \ | |
${{ github.sha }} \ | |
"main.user.js" \ | |
"main.user.js Update to version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')" \ | |
"Signed-off-by: 沙漠之子 <7850715+maboloshi@users.noreply.github.com>" |