goffmpeg/scripts/publish.sh

63 lines
1.4 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
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"