修改12
All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 7s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 7s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 13s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 13s
Build and Release / docker-images (push) Successful in 26s
Build and Release / release (push) Successful in 53s
All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 7s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 7s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 13s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 13s
Build and Release / docker-images (push) Successful in 26s
Build and Release / release (push) Successful in 53s
This commit is contained in:
@@ -178,7 +178,7 @@ jobs:
|
|||||||
echo " Package: ${PRODUCT_NAME}"
|
echo " Package: ${PRODUCT_NAME}"
|
||||||
echo " Version: ${TAG}"
|
echo " Version: ${TAG}"
|
||||||
|
|
||||||
# 上传所有包 (使用 PUT 方法)
|
# 上传所有包到 Generic Package Registry
|
||||||
for file in *.tar.gz; do
|
for file in *.tar.gz; do
|
||||||
[ ! -f "$file" ] && continue
|
[ ! -f "$file" ] && continue
|
||||||
echo " ⬆️ $file"
|
echo " ⬆️ $file"
|
||||||
@@ -191,20 +191,26 @@ jobs:
|
|||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
# 生成 Release 描述
|
# 生成 Release 描述(包含 Package Registry 和 Release 附件两种下载方式)
|
||||||
|
echo ""
|
||||||
echo "📝 生成 Release 描述..."
|
echo "📝 生成 Release 描述..."
|
||||||
BODY="## Release ${TAG}\n\n### 📥 下载链接\n"
|
BODY="## Release ${TAG}\n\n"
|
||||||
|
BODY="${BODY}### 📥 下载方式\n\n"
|
||||||
|
BODY="${BODY}#### 方式 1: 直接下载(推荐)\n\n"
|
||||||
|
BODY="${BODY}点击下面 **Assets** 部分的文件名直接下载。\n\n"
|
||||||
|
BODY="${BODY}#### 方式 2: Package Registry\n\n"
|
||||||
for file in *.tar.gz; do
|
for file in *.tar.gz; do
|
||||||
[ -f "$file" ] && BODY="${BODY}- [${file}](https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/${file})\n"
|
[ -f "$file" ] && BODY="${BODY}- [\`${file}\`](https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/${file})\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
# 创建 Release
|
# 创建 Release
|
||||||
|
echo ""
|
||||||
echo "🎉 创建 Release..."
|
echo "🎉 创建 Release..."
|
||||||
curl -fsSL -X POST \
|
RESPONSE=$(curl -fsSL -w "\n%{http_code}" -X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases" \
|
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||||
-d @- << EOF || echo "⚠️ Release 可能已存在"
|
-d @- << EOF
|
||||||
{
|
{
|
||||||
"tag_name": "${TAG}",
|
"tag_name": "${TAG}",
|
||||||
"name": "Release ${TAG}",
|
"name": "Release ${TAG}",
|
||||||
@@ -213,5 +219,44 @@ jobs:
|
|||||||
"prerelease": false
|
"prerelease": false
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||||
|
RESPONSE_BODY=$(echo "$RESPONSE" | head -n-1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "201" ]; then
|
||||||
|
echo "✅ Release 创建成功"
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE_BODY" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
echo " Release ID: ${RELEASE_ID}"
|
||||||
|
elif [ "$HTTP_CODE" = "409" ]; then
|
||||||
|
echo "⚠️ Release 已存在,获取现有 Release ID..."
|
||||||
|
RELEASE_ID=$(curl -fsSL \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases/tags/${TAG}" | \
|
||||||
|
grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
echo " Release ID: ${RELEASE_ID}"
|
||||||
|
else
|
||||||
|
echo "❌ 创建 Release 失败 (HTTP ${HTTP_CODE})"
|
||||||
|
echo "$RESPONSE_BODY"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 上传文件作为 Release 附件
|
||||||
|
echo ""
|
||||||
|
echo "📎 上传文件作为 Release 附件..."
|
||||||
|
for file in *.tar.gz; do
|
||||||
|
[ ! -f "$file" ] && continue
|
||||||
|
echo " ⬆️ $file"
|
||||||
|
|
||||||
|
# 使用 multipart/form-data 上传附件
|
||||||
|
curl -fsSL -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@${file}" \
|
||||||
|
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets?name=${file}" || {
|
||||||
|
echo " ⚠️ 附件上传失败: $file(可能已存在)"
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "✅ Release 创建完成!"
|
echo "✅ Release 创建完成!"
|
||||||
|
echo "🔗 访问: https://${REGISTRY}/${{ gitea.repository }}/releases/tag/${TAG}"
|
||||||
Reference in New Issue
Block a user