From 1a3dd05ba352abaa6d03d107b71bfe63e9d1a95a Mon Sep 17 00:00:00 2001 From: shaw Date: Wed, 23 Jul 2025 23:43:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20GitHub=20Action=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加工作流开始时的 VERSION 文件同步步骤 - 确保 VERSION 文件始终与最新 release 保持一致 - 移除不存在的 CHANGELOG.md 更新逻辑 - 解决因分支合并导致的版本不同步问题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/auto-release.yml | 47 +++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 122e56b5..643cf95a 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -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