Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7e079ac14 | ||
|
|
66caaba5bc |
@@ -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,10 +105,15 @@ 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 "")
|
||||
# Gitea 的 release JSON 里 "id" 会出现多次(author.id、repo.id…),
|
||||
# 必须先按逗号拆行,只取顶层那个 "id",否则会拿到 1
|
||||
# 顶层 "id" 在 Gitea 的 release JSON 里是最先出现的那个(后面 author.id/repo.id 才是 1)
|
||||
rid_of() { grep -o '"id":[0-9]*' | head -1 | cut -d: -f2; }
|
||||
RID=$(rid_of < /tmp/rel.json 2>/dev/null)
|
||||
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}" | rid_of)
|
||||
fi
|
||||
echo " 解析到 release id: ${RID}"
|
||||
if [ -n "$RID" ]; then
|
||||
curl -sS -X POST -H "$AUTH" -F "attachment=@way-node-linux-amd64" \
|
||||
"${API}/releases/${RID}/assets?name=way-node-linux-amd64" >/dev/null \
|
||||
|
||||
+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