From 57447882cb8a439a85ab82c620d82b6381b2833a Mon Sep 17 00:00:00 2001 From: zhilv Date: Tue, 26 May 2026 11:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(release):=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=8F=91=E5=B8=83=E8=84=9A=E6=9C=AC=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=20python3=20=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 发布脚本优先使用 python3,没有时再回退到 python - 修复 runner 仅提供 python3 时发布阶段直接失败的问题 - 保持 Release 创建和附件上传逻辑不变 --- scripts/publish-gitea-release.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/publish-gitea-release.sh b/scripts/publish-gitea-release.sh index fde3288..27e95e7 100755 --- a/scripts/publish-gitea-release.sh +++ b/scripts/publish-gitea-release.sh @@ -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"