fix: install.sh 兼容 Gitea 下载路径 + CI 补 curl
Build way-node / Build and Push (push) Successful in 1m16s
Build way-node / Build and Push (push) Successful in 1m16s
1) install.sh: Gitea 不支持 GitHub 的 /releases/latest/download/ 简写 (实测 404),改成先用 Gitea API /releases/latest 查 tag_name, 再拼 /releases/download/<tag>/<artifact>(实测 200,66875554 bytes)。 解析用 sed,不依赖 jq/python。 2) CI: 上一轮 release 上传静默失败,日志是 '/root/.cache/act/.../7.sh: line 6: curl: command not found' 根因是装 curl 的语句写在 'if ! command -v docker' 里面, 而 docker 本来就存在(runner 挂了 docker.sock),整段被跳过。 现在 curl 单独检查安装;release id 解析也从 python3 换成 sed。
This commit is contained in:
@@ -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" \
|
||||
|
||||
+11
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user