diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6b2834f..3486bb5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,30 +19,35 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - + - name: Check for code changes id: check_changes run: | - # 获取 24 小时前的时间戳 - TWENTY_FOUR_HOURS_AGO=$(date -d '24 hours ago' '+%Y-%m-%d %H:%M:%S') - - # 检查自 24 小时前以来是否有变更(排除.github 目录) - if git diff --quiet `git rev-list -n1 --before="$TWENTY_FOUR_HOURS_AGO" HEAD` HEAD -- ':!.github'; then + # 获取当前时间戳和 24 小时前的时间戳 + CURRENT_TIMESTAMP=$(date +%s) + TWENTY_FOUR_HOURS_AGO_TIMESTAMP=$((CURRENT_TIMESTAMP - 86400)) + + echo "Current timestamp: $CURRENT_TIMESTAMP" + echo "24 hours ago timestamp: $TWENTY_FOUR_HOURS_AGO_TIMESTAMP" + + echo "Commits in the last 24 hours:" + git log --since="@$TWENTY_FOUR_HOURS_AGO_TIMESTAMP" --format="%h %ct %s" + + echo "All changed files in the last 24 hours (including .github):" + git diff --name-only $(git rev-list -n1 --before="@$TWENTY_FOUR_HOURS_AGO_TIMESTAMP" HEAD) HEAD + + echo "Changed files excluding .github directory:" + CHANGED_FILES=$(git diff --name-only $(git rev-list -n1 --before="@$TWENTY_FOUR_HOURS_AGO_TIMESTAMP" HEAD) HEAD -- ':!.github') + + if [ -z "$CHANGED_FILES" ]; then echo "should_run=false" >> $GITHUB_OUTPUT - echo "No changes detected in the last 24 hours" + echo "No changes detected outside .github directory in the last 24 hours" else echo "should_run=true" >> $GITHUB_OUTPUT - echo "Changes detected in the last 24 hours" + echo "Changes detected outside .github directory in the last 24 hours:" + echo "$CHANGED_FILES" fi - # 输出调试信息 - echo "Current time: $(date '+%Y-%m-%d %H:%M:%S')" - echo "24 hours ago: $TWENTY_FOUR_HOURS_AGO" - echo "Commits in the last 24 hours:" - git log --since="24 hours ago" --oneline - echo "Files changed in the last 24 hours:" - git diff --name-only `git rev-list -n1 --before="$TWENTY_FOUR_HOURS_AGO" HEAD` HEAD -- ':!.github' - nightly-release: needs: check_changes if: needs.check_changes.outputs.should_run == 'true'