fix: 修复 GitHub Action 版本同步问题

- 添加工作流开始时的 VERSION 文件同步步骤
- 确保 VERSION 文件始终与最新 release 保持一致
- 移除不存在的 CHANGELOG.md 更新逻辑
- 解决因分支合并导致的版本不同步问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
shaw
2025-07-23 23:43:59 +08:00
parent b67cf05f63
commit 1a3dd05ba3

View File

@@ -23,6 +23,34 @@ 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
run: |
@@ -130,7 +158,7 @@ jobs:
- name: Update VERSION file
if: steps.check_changes.outputs.has_changes == 'true'
run: |
# 更新 VERSION 文件
# 强制更新 VERSION 文件为最新版本
echo "${{ steps.next_version.outputs.new_version }}" > VERSION
# 检查是否有更改
@@ -141,18 +169,17 @@ jobs:
echo "Updated VERSION file to ${{ steps.next_version.outputs.new_version }}"
fi
- name: Update CHANGELOG.md
- name: Commit VERSION update
if: steps.check_changes.outputs.has_changes == 'true'
run: |
# 生成完整的 CHANGELOG
git cliff --config .github/cliff.toml --output CHANGELOG.md
# 提交 CHANGELOG 和 VERSION 更新
if git diff --quiet CHANGELOG.md VERSION; then
echo "No changes to CHANGELOG.md or VERSION"
# 提交 VERSION 更新
if git diff --quiet VERSION; then
echo "No changes to VERSION"
else
git add CHANGELOG.md VERSION
git commit -m "chore: update CHANGELOG.md and VERSION for ${{ steps.next_version.outputs.new_tag }} [skip ci]"
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: update VERSION to ${{ steps.next_version.outputs.new_version }} for ${{ steps.next_version.outputs.new_tag }} [skip ci]"
git push origin main
fi