Compare commits
1
Commits
v0.1.0
..
5c924db235
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c924db235 |
@@ -32,11 +32,8 @@ jobs:
|
|||||||
bun build --target=bun --minify server/index.ts --outfile dist/patchbay/server/index.js
|
bun build --target=bun --minify server/index.ts --outfile dist/patchbay/server/index.js
|
||||||
cp -r web-dist dist/patchbay/web-dist
|
cp -r web-dist dist/patchbay/web-dist
|
||||||
echo "${GITHUB_REF_NAME}" > dist/patchbay/version.txt
|
echo "${GITHUB_REF_NAME}" > dist/patchbay/version.txt
|
||||||
cp dist/patchbay/version.txt version.txt
|
|
||||||
tar -czf patchbay.tar.gz -C dist patchbay
|
tar -czf patchbay.tar.gz -C dist patchbay
|
||||||
|
|
||||||
# version.txt 单独作为 asset 再传一份,install.sh check 用它比对版本,
|
|
||||||
# 不用把整个 tarball 拉下来。
|
|
||||||
# 直接 curl Gitea 的 API 而不用现成 action:gitea.com/actions/release-action
|
# 直接 curl Gitea 的 API 而不用现成 action:gitea.com/actions/release-action
|
||||||
# 是 Go 程序,runner 镜像里没有 Go 工具链,跑不起来
|
# 是 Go 程序,runner 镜像里没有 Go 工具链,跑不起来
|
||||||
- name: 发布 Release
|
- name: 发布 Release
|
||||||
@@ -55,8 +52,6 @@ jobs:
|
|||||||
# 响应里第一个 "id" 就是 release 自己的(嵌套对象如 author 排在它后面)
|
# 响应里第一个 "id" 就是 release 自己的(嵌套对象如 author 排在它后面)
|
||||||
id="$(printf '%s' "$resp" | grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2)"
|
id="$(printf '%s' "$resp" | grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2)"
|
||||||
[ -n "$id" ] || { echo "没拿到 release id,响应: $resp"; exit 1; }
|
[ -n "$id" ] || { echo "没拿到 release id,响应: $resp"; exit 1; }
|
||||||
for f in patchbay.tar.gz version.txt; do
|
curl -fsS -X POST -H "$auth" -F "attachment=@patchbay.tar.gz" \
|
||||||
curl -fsS -X POST -H "$auth" -F "attachment=@${f}" \
|
"$api/releases/${id}/assets?name=patchbay.tar.gz" >/dev/null
|
||||||
"$api/releases/${id}/assets?name=${f}" >/dev/null
|
echo "已上传 patchbay.tar.gz"
|
||||||
echo "已上传 $f"
|
|
||||||
done
|
|
||||||
|
|||||||
+12
-12
@@ -21,6 +21,7 @@ set -Eeuo pipefail
|
|||||||
SELF_VERSION="1.0.0"
|
SELF_VERSION="1.0.0"
|
||||||
|
|
||||||
REPO_URL="https://git.im0o.top/im0o/mihomo-patchbay"
|
REPO_URL="https://git.im0o.top/im0o/mihomo-patchbay"
|
||||||
|
API_URL="https://git.im0o.top/api/v1/repos/im0o/mihomo-patchbay"
|
||||||
# bun 版本钉死,避免运行时行为漂移;和 .gitea/workflows/release.yml 的构建版本一起改
|
# bun 版本钉死,避免运行时行为漂移;和 .gitea/workflows/release.yml 的构建版本一起改
|
||||||
BUN_VERSION="${PATCHBAY_BUN_VERSION:-1.3.14}"
|
BUN_VERSION="${PATCHBAY_BUN_VERSION:-1.3.14}"
|
||||||
|
|
||||||
@@ -108,12 +109,10 @@ gh_url() { # gh_url "owner/repo/releases/..." -> 完整
|
|||||||
printf '%s' "$u"
|
printf '%s' "$u"
|
||||||
}
|
}
|
||||||
|
|
||||||
release_url() { # release_url <asset> -> Gitea Release 下载地址
|
# 这台 Gitea 的网页路由没有 /releases/latest/download/<asset> 这种别名(实测 404),
|
||||||
if [[ -n "$WANT_VERSION" ]]; then
|
# 所以下载地址必须带具体版本号,「最新」由 latest_version 先问 API
|
||||||
printf '%s/releases/download/%s/%s' "$REPO_URL" "$WANT_VERSION" "$1"
|
release_url() { # release_url <版本> <asset> -> 下载地址
|
||||||
else
|
printf '%s/releases/download/%s/%s' "$REPO_URL" "$1" "$2"
|
||||||
printf '%s/releases/latest/download/%s' "$REPO_URL" "$1"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 读 config.yaml 顶层的简单键(形如 `secret: "xxx"`),套路取自 mihomo-up.sh 的 cfg_get
|
# 读 config.yaml 顶层的简单键(形如 `secret: "xxx"`),套路取自 mihomo-up.sh 的 cfg_get
|
||||||
@@ -129,11 +128,12 @@ installed_version() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
latest_version() {
|
latest_version() {
|
||||||
local v
|
local resp v
|
||||||
v="$(curl -fsSL --retry 2 --connect-timeout 5 --max-time 15 "$(release_url version.txt)" \
|
resp="$(curl -fsSL --retry 2 --connect-timeout 5 --max-time 15 "$API_URL/releases/latest")" \
|
||||||
| tr -d '[:space:]')" \
|
|| die "查询最新 Release 失败: $API_URL/releases/latest(还没发布过 Release?网络不通?)"
|
||||||
|| die "拉取版本号失败: $(release_url version.txt)(仓库还没发布过 Release?网络不通?)"
|
# 响应里 tag_name 只出现一次(release 对象自己的),不装 jq 也能取
|
||||||
[[ "$v" =~ ^v[0-9]+\.[0-9]+ ]] || die "拿到的版本号格式不对: $v"
|
v="$(printf '%s' "$resp" | grep -o '"tag_name":"[^"]*"' | head -n1 | cut -d'"' -f4)"
|
||||||
|
[[ "$v" =~ ^v[0-9]+\.[0-9]+ ]] || die "拿到的版本号格式不对: ${v:-空}"
|
||||||
printf '%s' "$v"
|
printf '%s' "$v"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ install_bun() {
|
|||||||
# ───────────────────────── 应用本体 ─────────────────────────
|
# ───────────────────────── 应用本体 ─────────────────────────
|
||||||
install_app() { # $1 = 目标版本
|
install_app() { # $1 = 目标版本
|
||||||
local target="$1" url
|
local target="$1" url
|
||||||
url="$(release_url patchbay.tar.gz)"
|
url="$(release_url "$target" patchbay.tar.gz)"
|
||||||
|
|
||||||
info "下载 patchbay.tar.gz"
|
info "下载 patchbay.tar.gz"
|
||||||
curl -fL -# --retry 3 --connect-timeout 15 --max-time 300 -o "$TMPDIR_/app.tar.gz" "$url" \
|
curl -fL -# --retry 3 --connect-timeout 15 --max-time 300 -o "$TMPDIR_/app.tar.gz" "$url" \
|
||||||
|
|||||||
Reference in New Issue
Block a user