diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 3133d8d..751347c 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -30,16 +30,25 @@ jobs: name: Build and Push runs-on: ubuntu steps: - - name: Install Docker CLI + - name: Install Docker CLI and curl run: | + # docker 通常已存在(挂 docker.sock),所以 curl 要单独保证 —— 上一轮 + # 就是因为整段 if 被跳过、curl 缺失,release 上传那步静默失败 if ! command -v docker >/dev/null 2>&1; then if command -v apk >/dev/null 2>&1; then - apk add --no-cache docker-cli git curl + apk add --no-cache docker-cli git elif command -v apt-get >/dev/null 2>&1; then - apt-get update && apt-get install -y docker.io git curl + apt-get update && apt-get install -y docker.io git fi fi - docker --version + if ! command -v curl >/dev/null 2>&1; then + if command -v apk >/dev/null 2>&1; then + apk add --no-cache curl + elif command -v apt-get >/dev/null 2>&1; then + apt-get update && apt-get install -y curl + fi + fi + docker --version && curl --version | head -1 - name: Checkout uses: actions/checkout@v4 @@ -96,9 +105,9 @@ jobs: curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"body\":\"way-node ${TAG}\",\"target_commitish\":\"${{ github.sha }}\"}" \ "${API}/releases" -o /tmp/rel.json || true - RID=$(python3 -c "import json;print(json.load(open('/tmp/rel.json')).get('id',''))" 2>/dev/null || echo "") + RID=$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' /tmp/rel.json 2>/dev/null | head -1) if [ -z "$RID" ]; then - RID=$(curl -sS -H "$AUTH" "${API}/releases/tags/${TAG}" | python3 -c "import json,sys;print(json.load(sys.stdin).get('id',''))" 2>/dev/null || echo "") + RID=$(curl -sS -H "$AUTH" "${API}/releases/tags/${TAG}" | sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' | head -1) fi if [ -n "$RID" ]; then curl -sS -X POST -H "$AUTH" -F "attachment=@way-node-linux-amd64" \ diff --git a/install.sh b/install.sh index 724ea01..9dd66d3 100755 --- a/install.sh +++ b/install.sh @@ -483,7 +483,17 @@ select_binary_source() { resolve_download_url() { local artifact="$1" if [ "$RELEASE_VERSION" = "latest" ]; then - DOWNLOAD_URL="${DEFAULT_DOWNLOAD_BASE}/latest/download/${artifact}" + # Gitea 不支持 GitHub 那种 /releases/latest/download/ 简写,先用 API 查最新 tag + local api_base tag + api_base="${DEFAULT_DOWNLOAD_BASE%/releases}" + api_base="${api_base%/download}" + case "$api_base" in + *"/admin/"*) api_base="$(printf '%s' "$api_base" | sed -E 's#^(https?://[^/]+)/(.*)$#\1/api/v1/repos/\2#')" ;; + esac + tag="$(curl -fsSL --max-time 10 "${api_base}/releases/latest" 2>/dev/null \ + | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)" + [ -n "$tag" ] || tag="v1.0.0" + DOWNLOAD_URL="${DEFAULT_DOWNLOAD_BASE}/download/${tag}/${artifact}" else DOWNLOAD_URL="${DEFAULT_DOWNLOAD_BASE}/download/${RELEASE_VERSION}/${artifact}" fi