chore: update publish script to use goproxy.cn

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kingecg 2026-03-21 08:07:00 +08:00
parent fd53f97770
commit aa049f9e0c
1 changed files with 62 additions and 0 deletions

62
scripts/publish.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
set -e
# 发布 goffmpeg 库到 goproxy.cn 和 pkg.go.dev
# 用法: ./scripts/publish.sh [version]
# 示例: ./scripts/publish.sh v1.0.0
REPO_URL="ssh://git.kingecg.top:2222/kingecg/goffmpeg.git"
MODULE_NAME="git.kingecg.top/kingecg/goffmpeg"
GOPROXY_URL="https://goproxy.cn"
# 检查未提交的更改
if [[ -n $(git status --porcelain) ]]; then
echo "Error: 有未提交的更改,请先提交"
exit 1
fi
# 获取版本号
if [[ -z "$1" ]]; then
echo "用法: $0 <version>"
echo "示例: $0 v1.0.0"
exit 1
fi
VERSION="$1"
# 验证版本格式
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: 版本格式不正确,应为 vMAJOR.MINOR.PATCH (如 v1.0.0)"
exit 1
fi
echo "=== 发布 goffmpeg ==="
echo "版本: $VERSION"
echo "模块: $MODULE_NAME"
echo "代理: $GOPROXY_URL"
echo ""
# 设置代理
export GOPROXY="$GOPROXY_URL,direct"
# 创建 tag
echo "1. 创建 tag: $VERSION"
git tag -a "$VERSION" -m "Release $VERSION" HEAD
# 推送 tag 到远程
echo "2. 推送 tag 到远程"
git push "$REPO_URL" "$VERSION"
# 通知代理
echo "3. 通知 goproxy.cn 抓取模块"
curl -s "https://goproxy.cn/notify?pkg=$MODULE_NAME" || true
echo ""
echo "=== 发布完成 ==="
echo ""
echo "模块已发布到 goproxy.cn可以直接使用:"
echo " go get $MODULE_NAME@$VERSION"
echo ""
echo "访问: https://pkg.go.dev/$MODULE_NAME"
echo ""
echo "注意: goproxy.cn 会自动抓取公开的 Git tags"