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 文件始终与最新 release 保持一致 - 移除不存在的 CHANGELOG.md 更新逻辑 - 解决因分支合并导致的版本不同步问题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
47
.github/workflows/auto-release.yml
vendored
47
.github/workflows/auto-release.yml
vendored
@@ -23,6 +23,34 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
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
|
- name: Get latest tag
|
||||||
id: get_latest_tag
|
id: get_latest_tag
|
||||||
run: |
|
run: |
|
||||||
@@ -130,7 +158,7 @@ jobs:
|
|||||||
- name: Update VERSION file
|
- name: Update VERSION file
|
||||||
if: steps.check_changes.outputs.has_changes == 'true'
|
if: steps.check_changes.outputs.has_changes == 'true'
|
||||||
run: |
|
run: |
|
||||||
# 更新 VERSION 文件
|
# 强制更新 VERSION 文件为最新版本
|
||||||
echo "${{ steps.next_version.outputs.new_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 }}"
|
echo "Updated VERSION file to ${{ steps.next_version.outputs.new_version }}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Update CHANGELOG.md
|
- name: Commit VERSION update
|
||||||
if: steps.check_changes.outputs.has_changes == 'true'
|
if: steps.check_changes.outputs.has_changes == 'true'
|
||||||
run: |
|
run: |
|
||||||
# 生成完整的 CHANGELOG
|
# 提交 VERSION 更新
|
||||||
git cliff --config .github/cliff.toml --output CHANGELOG.md
|
if git diff --quiet VERSION; then
|
||||||
|
echo "No changes to VERSION"
|
||||||
# 提交 CHANGELOG 和 VERSION 更新
|
|
||||||
if git diff --quiet CHANGELOG.md VERSION; then
|
|
||||||
echo "No changes to CHANGELOG.md or VERSION"
|
|
||||||
else
|
else
|
||||||
git add CHANGELOG.md VERSION
|
git config user.name "github-actions[bot]"
|
||||||
git commit -m "chore: update CHANGELOG.md and VERSION for ${{ steps.next_version.outputs.new_tag }} [skip ci]"
|
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
|
git push origin main
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user