Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m27s
- publish-update.sh:只让 tauri 打 .app(含 .app.tar.gz + .sig),dmg 改 hdiutil 封 —— create-dmg 的 bundle_dmg.sh 在 macOS 26.6.2 上必失败(grep: bad regex)。 - update-releases.js 记录内容指纹 h,gen-site / gen-release-page 的下载链接带 ?h=<sha12>: Cloudflare 对 updates/*.dmg 强缓存 4 小时,同名重传会返回旧字节(本次实测哈希对不上)。 - release.sh 校验按指纹回读;说明用数组传参(不再被空格拆词)。 - CHANGELOG 记入本次发布链路修复。 发布结果:latest.json 3.25.23,双架构 tar.gz + minisign 签名就位, aarch64 dmg 8,696,185 B / sha256 774a56bb… 与 releases.json 一致。
107 lines
5.4 KiB
Bash
Executable File
107 lines
5.4 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")/.."
|
||
|
||
[ $# -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 包单独构建:全局 version 提升后,旧 windows 条目会变成「声明新版本、实际旧安装包」,
|
||
# 客户端会因 app-version 绑定不一致而拒绝安装。所以每次发布 mac 时明确提示并丢弃过期的非 darwin 条目,
|
||
# 等 Windows 包跟上再用 publish-windows-update.sh 合并回来。
|
||
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
|
||
node -e '
|
||
const fs = require("fs")
|
||
let prev = {}
|
||
try { prev = JSON.parse(fs.readFileSync("/tmp/iwb-latest-prev.json", "utf8")) } catch (e) { prev = {} }
|
||
const stale = (prev.platforms ? Object.keys(prev.platforms) : []).filter(function (k) { return k.indexOf("darwin-") !== 0 && prev.version !== process.env.UPD_VERSION })
|
||
if (stale.length) console.log("将丢弃过期的非 darwin 平台条目:" + stale.join(","))
|
||
'
|
||
|
||
node -e '
|
||
const fs = require("fs")
|
||
const v = process.env.UPD_VERSION
|
||
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" },
|
||
},
|
||
}
|
||
fs.writeFileSync("/tmp/iwb-latest.json", JSON.stringify(j, null, 2))
|
||
console.log("latest.json -> v" + v)
|
||
'
|
||
$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"
|
||
|
||
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
|