Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
- scripts/release.sh、scripts/publish-update.sh:开头加前置门禁(不一致直接退出,不发包不传 NAS), 末尾加收尾复核(发布过程中若有人手改产物层,这里立刻暴露) - scripts/git-hooks/pre-push + scripts/install-git-hooks.sh + npm run hooks:install: 推送桌面仓前自动比对两仓,不一致拒绝推送;源仓不存在时跳过(CI/别人机器不阻塞) - docs/standards/plugin-source-of-truth.md §4 补「四道关卡」表与钩子安装方法
143 lines
8.3 KiB
Bash
Executable File
143 lines
8.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# 发布在线更新:签名构建(双架构)+ 上传产物 + 生成 latest.json
|
||
#
|
||
# 用法:
|
||
# ./scripts/publish-update.sh # 用 package.json 的版本
|
||
# ./scripts/publish-update.sh 3.25.3 # 先改版本再发布(等价于 set-version + 本脚本)
|
||
#
|
||
# 依赖:
|
||
# · 签名私钥:~/.config/iwb-updater.key(TAURI_SIGNING_PRIVATE_KEY)
|
||
# · 公钥已写进 src-tauri/tauri.conf.json → plugins.updater.pubkey
|
||
# · NAS 可 ssh(~/.ssh/id_ed25519_fnos)
|
||
#
|
||
# 产物:
|
||
# <target>/bundle/macos/image-workbench.app.tar.gz(.sig) ← 更新器用
|
||
# <target>/bundle/dmg/*.dmg ← 官网下载用
|
||
# https://download.maqiart.eu.org/updates/latest.json ← 更新源
|
||
set -euo pipefail
|
||
cd "$(dirname "$0")/.."
|
||
|
||
# 插件两仓一致性(v3.26.109):桌面仓 plugins/ 必须等于插件源仓,否则发布的包/市场会和源码分叉。
|
||
# 源仓不存在时脚本自身会跳过(CI / 别人机器不阻塞)。见 docs/standards/plugin-source-of-truth.md。
|
||
node scripts/check-plugins-sync.js || { echo '✗ 插件两仓不一致,已停止发布(先同步插件源仓)'; exit 1; }
|
||
|
||
[ $# -ge 1 ] && node scripts/set-version.js "$1"
|
||
V=$(node -e "console.log(require('./package.json').version)")
|
||
KEY="${TAURI_SIGNING_PRIVATE_KEY:-$HOME/.config/iwb-updater.key}"
|
||
export TAURI_SIGNING_PRIVATE_KEY="$KEY"
|
||
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD="${TAURI_SIGNING_PRIVATE_KEY_PASSWORD:-}"
|
||
export CARGO_HOME="${CARGO_HOME:-$PWD/.cargo-home}"
|
||
|
||
NAS_HOST="${NAS_HOST:-malongan@192.168.100.185}"
|
||
NAS_DIR="${NAS_DIR:-/vol8/web/iwb-download}"
|
||
SSH_KEY="${SSH_KEY:-$HOME/.ssh/id_ed25519_fnos}"
|
||
SCP="scp -i $SSH_KEY -o BatchMode=yes"
|
||
|
||
# macOS 26(26.6.2 实测)上 tauri 自带的 create-dmg / bundle_dmg.sh 会在
|
||
# "Searching for mounted interstitial disk image" 处报 `grep: bad regex` 并中止,
|
||
# 整条发布链因此断在 dmg 上(而 .app 与签名产物其实已经生成)。
|
||
# 所以:只让 tauri 打 app(含 .app.tar.gz + .sig),dmg 用 hdiutil 自己封。
|
||
make_dmg() { # $1=app 路径 $2=输出 dmg
|
||
local app="$1" out="$2" stage
|
||
stage=$(mktemp -d)
|
||
cp -R "$app" "$stage/"
|
||
ln -s /Applications "$stage/Applications"
|
||
rm -f "$out"
|
||
hdiutil create -volname "image-workbench" -srcfolder "$stage" -ov -format UDZO -quiet "$out"
|
||
rm -rf "$stage"
|
||
}
|
||
|
||
echo "== 1/4 构建 arm64(app + 签名产物)"
|
||
npx tauri build --bundles app >/dev/null
|
||
|
||
echo "== 2/4 构建 x86_64(app + 签名产物)"
|
||
npx tauri build --target x86_64-apple-darwin --bundles app >/dev/null
|
||
|
||
ARM="src-tauri/target/release/bundle"
|
||
INT="src-tauri/target/x86_64-apple-darwin/release/bundle"
|
||
mkdir -p "$ARM/dmg" "$INT/dmg"
|
||
echo "== 封装 dmg"
|
||
make_dmg "$ARM/macos/image-workbench.app" "$ARM/dmg/image-workbench_${V}_aarch64.dmg"
|
||
make_dmg "$INT/macos/image-workbench.app" "$INT/dmg/image-workbench_${V}_x64.dmg"
|
||
|
||
echo "== 3/4 上传产物"
|
||
TMP=$(mktemp -d)
|
||
cp "$ARM/macos/image-workbench.app.tar.gz" "$TMP/image-workbench_${V}_aarch64.app.tar.gz"
|
||
cp "$ARM/macos/image-workbench.app.tar.gz.sig" "$TMP/image-workbench_${V}_aarch64.app.tar.gz.sig"
|
||
cp "$INT/macos/image-workbench.app.tar.gz" "$TMP/image-workbench_${V}_x64.app.tar.gz"
|
||
cp "$INT/macos/image-workbench.app.tar.gz.sig" "$TMP/image-workbench_${V}_x64.app.tar.gz.sig"
|
||
$SCP "$TMP"/*.app.tar.gz* "$NAS_HOST:$NAS_DIR/updates/darwin-aarch64/" 2>/dev/null || true
|
||
$SCP "$TMP/image-workbench_${V}_aarch64.app.tar.gz" "$TMP/image-workbench_${V}_aarch64.app.tar.gz.sig" "$NAS_HOST:$NAS_DIR/updates/darwin-aarch64/"
|
||
$SCP "$TMP/image-workbench_${V}_x64.app.tar.gz" "$TMP/image-workbench_${V}_x64.app.tar.gz.sig" "$NAS_HOST:$NAS_DIR/updates/darwin-x86_64/"
|
||
$SCP "$ARM/dmg/image-workbench_${V}_aarch64.dmg" "$NAS_HOST:$NAS_DIR/updates/darwin-aarch64/"
|
||
$SCP "$INT/dmg/image-workbench_${V}_x64.dmg" "$NAS_HOST:$NAS_DIR/updates/darwin-x86_64/"
|
||
|
||
echo "== 4/4 生成 latest.json"
|
||
export SIG_ARM="$(cat "$ARM/macos/image-workbench.app.tar.gz.sig")"
|
||
export SIG_INT="$(cat "$INT/macos/image-workbench.app.tar.gz.sig")"
|
||
export UPD_VERSION="$V"
|
||
# Windows 包由 win 端构建、mac 端 publish-windows-update.sh 签名发布,写独立的 latest-windows.json。
|
||
# 但应用 endpoints 只配了 latest.json(mac/win 共用同一份 tauri.conf.json,无法按平台分 endpoint),
|
||
# 所以 mac 发布【必须】把 windows 条目合并进 latest.json,否则 win 用户「检查更新」找不到自己平台、
|
||
# 会卡在「正在检查…」(v3.25.31 实测踩过:旧逻辑硬编码只写 darwin,每次 mac 发版都抹掉 windows 条目)。
|
||
# 合并条件:latest-windows.json 的 version == 本次 mac version(三平台同批)。
|
||
# 若 win 还没跟上本次版本,【不合并】——避免「顶层 version 新、win 包旧」让 updater 反复提示同一旧包;
|
||
# 等 win 同批发布后重跑本脚本即自动齐平。
|
||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest.json -o /tmp/iwb-latest-prev.json 2>/dev/null || echo '{}' > /tmp/iwb-latest-prev.json
|
||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest-windows.json -o /tmp/iwb-latest-win.json 2>/dev/null || echo '{}' > /tmp/iwb-latest-win.json
|
||
|
||
node -e '
|
||
const fs = require("fs")
|
||
const v = process.env.UPD_VERSION
|
||
let win = {}
|
||
try { win = JSON.parse(fs.readFileSync("/tmp/iwb-latest-win.json", "utf8")) } catch (e) { win = {} }
|
||
const j = {
|
||
version: v,
|
||
notes: process.env.UPD_NOTES || "",
|
||
pub_date: new Date().toISOString(),
|
||
platforms: {
|
||
"darwin-aarch64": { signature: process.env.SIG_ARM, url: "https://download.maqiart.eu.org/updates/darwin-aarch64/image-workbench_" + v + "_aarch64.app.tar.gz" },
|
||
"darwin-x86_64": { signature: process.env.SIG_INT, url: "https://download.maqiart.eu.org/updates/darwin-x86_64/image-workbench_" + v + "_x64.app.tar.gz" },
|
||
},
|
||
}
|
||
if (win.platforms && win.platforms["windows-x86_64"]) {
|
||
if (win.version === v) {
|
||
j.platforms["windows-x86_64"] = win.platforms["windows-x86_64"]
|
||
console.log("已合并 windows-x86_64 条目(v" + v + ",三平台齐平)")
|
||
} else {
|
||
console.log("⚠ latest-windows.json 仍是 v" + win.version + ",本次 mac 发 v" + v + ":latest.json 暂不含 windows 条目。win 用户停留旧版,待 win 同批发布后【重跑本脚本】即自动齐平(切勿手工塞旧 win 包,会触发 updater 版本错配死循环)。")
|
||
}
|
||
}
|
||
fs.writeFileSync("/tmp/iwb-latest.json", JSON.stringify(j, null, 2))
|
||
console.log("latest.json -> v" + v + " platforms: " + Object.keys(j.platforms).join(","))
|
||
'
|
||
$SCP /tmp/iwb-latest.json "$NAS_HOST:$NAS_DIR/updates/latest.json"
|
||
ssh -i "$SSH_KEY" -o BatchMode=yes "$NAS_HOST" "chmod -R a+rX $NAS_DIR"
|
||
|
||
# == 自动对齐文档锚点 ==
|
||
# 规则:main = <sha> 必须是「最近一次 bump 版本的提交」。以前每次发版要手工改两次锚点,
|
||
# 现在由发布脚本收尾:写锚点 + 同步 facts + 本地提交(推送仍随版本一起做)。
|
||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||
HEAD_V=$(git show HEAD:package.json 2>/dev/null | node -e 'let t="";process.stdin.on("data",d=>t+=d).on("end",()=>{try{console.log(JSON.parse(t).version)}catch(e){console.log("")}})') || true
|
||
if [ "$HEAD_V" != "$V" ]; then
|
||
echo "WARN 版本号尚未提交(HEAD=${HEAD_V} 本地=${V}):跳过锚点自动对齐,请先提交再发布"
|
||
else
|
||
BUMP_SHA=$(git log -1 --format=%h -- package.json || true)
|
||
if [ -n "$BUMP_SHA" ]; then
|
||
node scripts/set-doc-anchor.js "$V" "$BUMP_SHA" || true
|
||
node scripts/sync-facts.js --write >/dev/null 2>&1 || true
|
||
if ! git diff --quiet -- docs/standards/architecture-current-state.md CONTRIBUTING.md 2>/dev/null; then
|
||
git add docs/standards/architecture-current-state.md CONTRIBUTING.md 2>/dev/null || true
|
||
GIT_AUTHOR_NAME=qiqi GIT_AUTHOR_EMAIL=qiqi@local GIT_COMMITTER_NAME=qiqi GIT_COMMITTER_EMAIL=qiqi@local git commit -q -m "docs: 锚点对齐 v${V}+${BUMP_SHA}(publish 自动)" || true
|
||
echo "== 文档锚点已自动对齐并本地提交:${BUMP_SHA}(随版本一起 push)"
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
echo "== 完成:https://download.maqiart.eu.org/updates/latest.json"
|
||
curl -s -m 15 https://download.maqiart.eu.org/updates/latest.json | head -c 200; echo
|
||
|
||
# 收尾再核一次:发布过程中若有人手改了产物层,这里会立刻暴露。
|
||
node scripts/check-plugins-sync.js || { echo '⚠ 收尾校验失败:插件两仓已不一致,请按 docs/standards/plugin-source-of-truth.md 回写源仓'; exit 1; }
|