chore(release): 加 publish-windows-update.sh(Windows 安装包本机重签名 + latest.json 合并)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m6s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m6s
This commit is contained in:
1 parent
91ab3511ea
commit
fc199776d9
1 file changed
+64
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
# 发布 Windows 更新:对 Windows 侧构建好的 *-setup.exe 重新签名(用本机正式私钥),
|
||||
# 上传到 NAS,并把 windows-x86_64 条目合并进 updates/latest.json。
|
||||
#
|
||||
# 用法:./scripts/publish-windows-update.sh "/path/to/image-workbench_3.25.3_x64-setup.exe"
|
||||
#
|
||||
# 背景(Tauri v2):Windows 的更新产物就是安装包本体 + 同名 .sig,没有 v1 的 *.nsis.zip。
|
||||
# Windows 机器只需把 setup.exe 发过来,签名与发布都在本机完成,私钥不外传。
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
EXE_IN="${1:?用法: publish-windows-update.sh <setup.exe 路径>}"
|
||||
[ -f "$EXE_IN" ] || { echo "找不到文件:$EXE_IN"; exit 1; }
|
||||
|
||||
V=$(node -e "console.log(require('./package.json').version)")
|
||||
KEY="${TAURI_SIGNING_PRIVATE_KEY:-$HOME/.config/iwb-updater.key}"
|
||||
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"
|
||||
|
||||
WORK=$(mktemp -d)
|
||||
OUT="$WORK/image-workbench_${V}_x64-setup.exe"
|
||||
cp "$EXE_IN" "$OUT"
|
||||
echo "== 1/4 校验文件"
|
||||
SIZE=$(stat -f%z "$OUT")
|
||||
SHA=$(shasum -a 256 "$OUT" | awk '{print $1}')
|
||||
echo " $OUT"
|
||||
echo " size=$SIZE sha256=$SHA"
|
||||
|
||||
echo "== 2/4 用正式私钥签名"
|
||||
npx tauri signer sign -f "$KEY" -p "${TAURI_SIGNING_PRIVATE_KEY_PASSWORD:-}" --app-version "$V" "$OUT" >/dev/null
|
||||
SIG_FILE="$OUT.sig"
|
||||
[ -f "$SIG_FILE" ] || { echo "签名失败:没有产出 $SIG_FILE"; exit 1; }
|
||||
echo " .sig $(wc -c < "$SIG_FILE" | tr -d ' ') 字节"
|
||||
|
||||
echo "== 3/4 上传到 NAS"
|
||||
ssh -i "$SSH_KEY" -o BatchMode=yes "$NAS_HOST" "mkdir -p $NAS_DIR/updates/windows-x86_64"
|
||||
$SCP "$OUT" "$SIG_FILE" "$NAS_HOST:$NAS_DIR/updates/windows-x86_64/"
|
||||
|
||||
echo "== 4/4 合并 latest.json"
|
||||
SIG=$(cat "$SIG_FILE")
|
||||
URL="https://download.maqiart.eu.org/updates/windows-x86_64/image-workbench_${V}_x64-setup.exe"
|
||||
export SIG URL APP_VERSION="$V"
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest.json -o "$WORK/latest.json" || echo '{}' > "$WORK/latest.json"
|
||||
node -e '
|
||||
const fs = require("fs")
|
||||
const p = process.argv[1]
|
||||
let cur = {}
|
||||
try { cur = JSON.parse(fs.readFileSync(p, "utf8")) } catch (e) { cur = {} }
|
||||
cur.version = process.env.APP_VERSION
|
||||
cur.notes = cur.notes || "在线更新"
|
||||
cur.pub_date = new Date().toISOString()
|
||||
cur.platforms = cur.platforms || {}
|
||||
cur.platforms["windows-x86_64"] = { signature: process.env.SIG, url: process.env.URL }
|
||||
fs.writeFileSync(p, JSON.stringify(cur, null, 2))
|
||||
console.log(" platforms:", Object.keys(cur.platforms).join(", "))
|
||||
' "$WORK/latest.json"
|
||||
$SCP "$WORK/latest.json" "$NAS_HOST:$NAS_DIR/updates/latest.json"
|
||||
ssh -i "$SSH_KEY" -o BatchMode=yes "$NAS_HOST" "chmod -R a+rX $NAS_DIR"
|
||||
|
||||
echo "== 完成"
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest.json | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const j=JSON.parse(s);console.log("version",j.version);for(const k of Object.keys(j.platforms))console.log(" -",k,"sig",(j.platforms[k].signature||"").length,"bytes")})'
|
||||
curl -s -o /dev/null -m 60 -w "exe:%{http_code} size:%{size_download}\n" "$URL"
|
||||
Reference in new issue
Block a user