mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
- 删除旧的auto-release.yml工作流,避免循环触发问题 - 新增auto-version-bump.yml:自动同步VERSION文件与release版本 - 新增release-on-version.yml:基于VERSION文件变更自动创建release - 更新docker-publish.yml:简化触发条件,仅在tag推送时构建 - 添加RELEASE_PROCESS.md文档:详细说明新的发布流程 - 修复web管理界面:解决OAuth账户token刷新和代理配置相关问题 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
102 lines
3.3 KiB
YAML
102 lines
3.3 KiB
YAML
name: Auto Version Bump
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- main
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
version-bump:
|
||
runs-on: ubuntu-latest
|
||
# 跳过由GitHub Actions创建的提交,避免死循环
|
||
if: github.event.pusher.name != 'github-actions[bot]'
|
||
steps:
|
||
- name: Checkout code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0
|
||
token: ${{ secrets.GITHUB_TOKEN }}
|
||
|
||
- name: Check if version bump is needed
|
||
id: check
|
||
run: |
|
||
# 获取当前提交的文件变更
|
||
CHANGED_FILES=$(git diff --name-only HEAD~1..HEAD 2>/dev/null || git diff --name-only $(git rev-list --max-parents=0 HEAD)..HEAD)
|
||
echo "Changed files:"
|
||
echo "$CHANGED_FILES"
|
||
|
||
# 检查是否只有无关文件(.md, docs/, .github/等)
|
||
SIGNIFICANT_CHANGES=false
|
||
while IFS= read -r file; do
|
||
# 跳过空行
|
||
[ -z "$file" ] && continue
|
||
|
||
# 检查是否是需要忽略的文件
|
||
if [[ ! "$file" =~ \.(md|txt)$ ]] &&
|
||
[[ ! "$file" =~ ^docs/ ]] &&
|
||
[[ ! "$file" =~ ^\.github/ ]] &&
|
||
[[ "$file" != "VERSION" ]] &&
|
||
[[ "$file" != ".gitignore" ]] &&
|
||
[[ "$file" != "LICENSE" ]]; then
|
||
echo "Found significant change in: $file"
|
||
SIGNIFICANT_CHANGES=true
|
||
break
|
||
fi
|
||
done <<< "$CHANGED_FILES"
|
||
|
||
if [ "$SIGNIFICANT_CHANGES" = true ]; then
|
||
echo "Significant changes detected, version bump needed"
|
||
echo "needs_bump=true" >> $GITHUB_OUTPUT
|
||
else
|
||
echo "No significant changes, skipping version bump"
|
||
echo "needs_bump=false" >> $GITHUB_OUTPUT
|
||
fi
|
||
|
||
- name: Get current version
|
||
if: steps.check.outputs.needs_bump == 'true'
|
||
id: get_version
|
||
run: |
|
||
# 获取最新的tag版本
|
||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||
echo "Latest tag: $LATEST_TAG"
|
||
|
||
# 从tag中提取版本号
|
||
VERSION=${LATEST_TAG#v}
|
||
echo "Current version: $VERSION"
|
||
echo "current_version=$VERSION" >> $GITHUB_OUTPUT
|
||
|
||
- name: Calculate next version
|
||
if: steps.check.outputs.needs_bump == 'true'
|
||
id: next_version
|
||
run: |
|
||
VERSION="${{ steps.get_version.outputs.current_version }}"
|
||
|
||
# 分割版本号
|
||
IFS='.' read -r -a version_parts <<< "$VERSION"
|
||
MAJOR="${version_parts[0]:-0}"
|
||
MINOR="${version_parts[1]:-0}"
|
||
PATCH="${version_parts[2]:-0}"
|
||
|
||
# 默认递增patch版本
|
||
NEW_PATCH=$((PATCH + 1))
|
||
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
||
|
||
echo "New version: $NEW_VERSION"
|
||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||
|
||
- name: Update VERSION file
|
||
if: steps.check.outputs.needs_bump == 'true'
|
||
run: |
|
||
echo "${{ steps.next_version.outputs.new_version }}" > VERSION
|
||
|
||
# 配置git
|
||
git config user.name "github-actions[bot]"
|
||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||
|
||
# 提交VERSION文件
|
||
git add VERSION
|
||
git commit -m "chore: bump version to ${{ steps.next_version.outputs.new_version }}"
|
||
git push origin main |