🐛 fix(release): 兼容发布脚本中的 python3 环境

- 发布脚本优先使用 python3,没有时再回退到 python
- 修复 runner 仅提供 python3 时发布阶段直接失败的问题
- 保持 Release 创建和附件上传逻辑不变
This commit is contained in:
2026-05-26 11:00:07 +08:00
parent 9b63ef38c3
commit 57447882cb

View File

@@ -110,8 +110,18 @@ require_cmd() {
command -v "$1" >/dev/null 2>&1 || fail "缺少命令:$1"
}
detect_python() {
if command -v python3 >/dev/null 2>&1; then
echo "python3"
elif command -v python >/dev/null 2>&1; then
echo "python"
else
return 1
fi
}
json_escape() {
python -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
"$PYTHON_BIN" -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
}
api_url() {
@@ -131,7 +141,7 @@ api_post_json() {
}
release_id_from_json() {
python -c 'import json,sys; print(json.load(sys.stdin)["id"])'
"$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin)["id"])'
}
[[ -n "$TAG" ]] || fail "必须指定 --tag"
@@ -141,7 +151,7 @@ release_id_from_json() {
require_cmd curl
require_cmd git
require_cmd python
PYTHON_BIN="$(detect_python)" || fail "缺少命令python 或 python3"
for package in "${PACKAGES[@]}"; do
[[ -f "$package" ]] || fail "发布包不存在:$package"