Files
alibabacloud-eci/scripts/release.sh
D8D Developer 7d5e8c1c21
Some checks failed
Virtual Kubelet Docker Build and Deploy / build-and-deploy (push) Has been cancelled
🔧 chore(scripts): 更新发布脚本中的远程仓库引用
- 将硬编码的远程仓库名称从 'gitea' 更改为 'origin' 以提升通用性
- 更新标签获取、代码拉取、标签推送和构建进度链接中的远程引用
- 确保脚本在不同仓库配置下都能正常工作
2026-01-02 00:58:55 +00:00

88 lines
2.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 发布脚本
# 使用方法: ./release.sh <版本号>
# 例如: ./release.sh 1.0.0
# 查看标签: ./release.sh --list 或 ./release.sh -l
set -e
# 检查参数
if [ $# -eq 0 ]; then
echo "错误: 请提供版本号"
echo "使用方法: $0 <版本号>"
echo "例如: $0 1.0.0"
echo ""
echo "📋 Gitea 最近10个标签:"
# 尝试获取远程标签,如果失败则使用本地标签
REMOTE_TAGS=$(git ls-remote --tags origin 2>/dev/null | grep -v "\^{}" | cut -f 2 | sed 's|refs/tags/||')
if [ -z "$REMOTE_TAGS" ]; then
echo "⚠️ 无法获取远程标签显示本地最近10个标签:"
git tag --list | sort -V | tail -10
else
echo "$REMOTE_TAGS" | sort -V | uniq | tail -10
fi
exit 1
fi
# 特殊参数: 查看所有标签
if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
echo "📋 Gitea 所有标签:"
# 尝试获取远程标签,如果失败则使用本地标签
REMOTE_TAGS=$(git ls-remote --tags origin 2>/dev/null | grep -v "\^{}" | cut -f 2 | sed 's|refs/tags/||')
if [ -z "$REMOTE_TAGS" ]; then
echo "⚠️ 无法获取远程标签,显示本地标签:"
git tag --list | sort -V
else
echo "$REMOTE_TAGS" | sort -V | uniq
fi
exit 0
fi
VERSION="$1"
TAG="v$VERSION"
# 验证版本号格式
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "错误: 版本号格式不正确,请使用语义化版本格式 (例如: 1.0.0)"
exit 1
fi
echo "🚀 开始发布 版本: $VERSION"
# 检查工作目录是否干净
if [ -n "$(git status --porcelain)" ]; then
echo "⚠️ 警告: 工作目录有未提交的更改"
git status
read -p "是否继续发布? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "发布已取消"
exit 1
fi
fi
# 检查当前分支
CURRENT_BRANCH=$(git branch --show-current)
echo "🌿 当前分支: $CURRENT_BRANCH"
# 拉取最新代码
echo "📥 拉取最新代码..."
git pull origin "$CURRENT_BRANCH"
# 创建标签
echo "🏷️ 创建标签 $TAG..."
git tag "$TAG"
# 推送标签
echo "📤 推送标签到远程仓库..."
git push origin "$TAG"
echo ""
echo "🎉 发布流程已启动!"
echo "📋 版本: $VERSION"
echo "🏷️ 标签: $TAG"
echo "🔗 GitHub Actions 将自动构建和发布 Docker 镜像"
echo ""
echo "📊 查看构建进度: $(git config --get remote.origin.url | sed 's|^ssh://||' | sed 's|^git@||' | sed 's|:|/|' | sed 's|\.git$||')/actions"