ci(release): publish 失败不再静默
- curl 加 -f,4xx/5xx 直接中断,不再无条件打印 OK - 再校验响应体的 fail/success,业务层异常同样中断 - 避免出现 tag 已创建、包却没上线的假成功
This commit is contained in:
@@ -281,8 +281,22 @@ jobs:
|
||||
API_TOKEN: ${{ secrets.TIMI_API_TOKEN }}
|
||||
RELEASE_ID: ${{ steps.create.outputs.release_id }}
|
||||
run: |
|
||||
curl -sS -X POST "$API_BASE_URL/app/release/publish?releaseId=$RELEASE_ID&channelCode=stable" \
|
||||
-H "Token: $API_TOKEN"
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "FAIL: 缺少发布记录 ID"
|
||||
exit 1
|
||||
fi
|
||||
# -f 让 4xx/5xx 直接失败;否则下面那句 OK 会照打,tag 也会照建
|
||||
response=$(curl -sS -f -X POST "$API_BASE_URL/app/release/publish?releaseId=$RELEASE_ID&channelCode=stable" \
|
||||
-H "Token: $API_TOKEN") || {
|
||||
echo "FAIL: 发布接口调用失败"
|
||||
exit 1
|
||||
}
|
||||
echo "响应:$response"
|
||||
# 业务层异常仍可能是 200 + fail:true,这里再兜一层
|
||||
if printf '%s' "$response" | grep -qE '"fail"[[:space:]]*:[[:space:]]*true|"success"[[:space:]]*:[[:space:]]*false'; then
|
||||
echo "FAIL: 发布未生效,请检查后端日志"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK: 已发布到 stable"
|
||||
|
||||
# 打 tag 的时机是「上线成功」而不是「PR 合并」:草稿发布和失败发布都不该留下版本标记。
|
||||
|
||||
Reference in New Issue
Block a user