mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: 修复 GitHub Action 版本同步死循环问题
- 移除工作流开始时的VERSION同步步骤,避免产生新提交导致无限循环 - 修改变更检查逻辑,忽略仅修改VERSION文件的提交 - 在工作流结束时确保VERSION文件与最新release同步 - 解决了VERSION文件追不上releases版本的问题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
62
.github/workflows/auto-release.yml
vendored
62
.github/workflows/auto-release.yml
vendored
@@ -23,33 +23,6 @@ jobs:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Sync VERSION file with latest release
|
||||
run: |
|
||||
# 获取所有标签并排序
|
||||
LATEST_TAG=$(git tag --sort=-version:refname | head -1 || echo "v0.0.0")
|
||||
if [ "$LATEST_TAG" != "v0.0.0" ]; then
|
||||
# 提取版本号(去掉 v 前缀)
|
||||
LATEST_VERSION=${LATEST_TAG#v}
|
||||
|
||||
# 读取当前 VERSION 文件
|
||||
CURRENT_VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0")
|
||||
|
||||
# 如果版本不一致,强制同步
|
||||
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
|
||||
echo "Syncing VERSION file: $CURRENT_VERSION -> $LATEST_VERSION"
|
||||
echo "$LATEST_VERSION" > VERSION
|
||||
git add VERSION
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "chore: sync VERSION file with release $LATEST_TAG [skip ci]" || echo "No changes to commit"
|
||||
git push origin main || echo "Nothing to push"
|
||||
|
||||
# 更新本地仓库状态
|
||||
git pull origin main --rebase || echo "No changes to pull"
|
||||
else
|
||||
echo "VERSION file is already in sync: $CURRENT_VERSION"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Get latest tag
|
||||
id: get_latest_tag
|
||||
@@ -105,15 +78,20 @@ jobs:
|
||||
- name: Check if there are changes to release
|
||||
id: check_changes
|
||||
run: |
|
||||
# 检查自上次标签以来是否有新的提交
|
||||
# 检查自上次标签以来是否有新的提交(排除只修改VERSION文件的提交)
|
||||
LATEST_TAG="${{ steps.get_latest_tag.outputs.latest_tag }}"
|
||||
if [ "$LATEST_TAG" = "v0.0.0" ]; then
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
CHANGES=$(git rev-list $LATEST_TAG..HEAD --count)
|
||||
if [ "$CHANGES" -gt 0 ]; then
|
||||
# 获取除了VERSION文件外的其他文件变更
|
||||
CHANGED_FILES=$(git diff --name-only $LATEST_TAG..HEAD | grep -v "^VERSION$" || true)
|
||||
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
echo "Found changes in files other than VERSION:"
|
||||
echo "$CHANGED_FILES"
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "No significant changes found (only VERSION file changed)"
|
||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
fi
|
||||
@@ -264,4 +242,26 @@ jobs:
|
||||
}' | \
|
||||
curl -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @-
|
||||
-d @-
|
||||
|
||||
- name: Ensure VERSION file is in sync
|
||||
if: always()
|
||||
run: |
|
||||
# 在工作流结束时确保VERSION文件与最新tag同步
|
||||
LATEST_TAG=$(git tag --sort=-version:refname | head -1 || echo "v0.0.0")
|
||||
if [ "$LATEST_TAG" != "v0.0.0" ]; then
|
||||
LATEST_VERSION=${LATEST_TAG#v}
|
||||
CURRENT_VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0")
|
||||
|
||||
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
|
||||
echo "Updating VERSION file to match latest release: $CURRENT_VERSION -> $LATEST_VERSION"
|
||||
echo "$LATEST_VERSION" > VERSION
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add VERSION
|
||||
git commit -m "chore: sync VERSION file with release $LATEST_TAG [skip ci]" || echo "No changes to commit"
|
||||
git push origin main || echo "Nothing to push"
|
||||
else
|
||||
echo "VERSION file is already in sync: $CURRENT_VERSION"
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user