feat: 增加桌面端安装包与分支专用 CI/CD

拆分后台服务、浏览器安装器和桌面托盘控制器,支持 Windows Service、macOS LaunchAgent 以及 Linux systemd 部署。

新增 Windows Inno Setup 安装器、macOS Intel/Apple Silicon 通用 pkg、Linux 多架构安装脚本,并在安装过程中自动准备 Playwright Chromium。

新增仅 codex/desktop-packaging 分支触发的桌面端 CI/CD,覆盖 Go 测试、交叉编译和 Windows/macOS/Linux 安装包构建;保持现有 Docker 工作流不变。

补充数据密钥持久化、托盘图标、安装文档及相关测试。
This commit is contained in:
Christ committed 2026-08-11 19:52:34 +08:00
1 parent 1204655170
commit a99ea5c20d
25 files changed
+1141 -81

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.christ.ydisks-xianyu-helper</string>
<key>CFBundleName</key>
<string>Ydisks Xianyu Helper</string>
<key>CFBundleDisplayName</key>
<string>闲鱼管家</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>__VERSION__</string>
<key>CFBundleShortVersionString</key>
<string>__VERSION__</string>
<key>LSUIElement</key>
<true/>
<key>CFBundleExecutable</key>
<string>xianyu-tray</string>
</dict>
</plist>
+25
View File
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu
VERSION="${1:?version is required}"
DIST_DIR="${2:?dist directory is required}"
ROOT_DIR="$DIST_DIR/pkgroot"
APP="$ROOT_DIR/Applications/Ydisks Xianyu Helper.app"
rm -rf "$ROOT_DIR"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Helpers" "$APP/Contents/Resources"
cp "$DIST_DIR/xianyu-server" "$APP/Contents/Helpers/xianyu-server"
cp "$DIST_DIR/browser-install" "$APP/Contents/Helpers/browser-install"
cp "$DIST_DIR/xianyu-tray" "$APP/Contents/MacOS/xianyu-tray"
cp "$(dirname "$0")/com.christ.ydisks-xianyu-helper.server.plist.template" "$APP/Contents/Resources/"
cp "$(dirname "$0")/com.christ.ydisks-xianyu-helper.tray.plist.template" "$APP/Contents/Resources/"
sed "s/__VERSION__/$VERSION/g" "$(dirname "$0")/Info.plist" > "$APP/Contents/Info.plist"
chmod 0755 "$APP/Contents/MacOS/xianyu-tray" "$APP/Contents/Helpers/xianyu-server" "$APP/Contents/Helpers/browser-install"
pkgbuild \
--root "$ROOT_DIR" \
--scripts "$(dirname "$0")/scripts" \
--identifier com.christ.ydisks-xianyu-helper \
--version "$VERSION" \
--install-location / \
"$DIST_DIR/Ydisks-Xianyu-Helper-$VERSION.pkg"
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>com.christ.ydisks-xianyu-helper.server</string>
<key>ProgramArguments</key>
<array>
<string>__SERVER__</string>
<string>-addr</string><string>127.0.0.1:8080</string>
<string>-workdir</string><string>__DATA_DIR__</string>
<string>-data-key-file</string><string>__DATA_KEY__</string>
<string>-playwright-driver-dir</string><string>__DRIVER_DIR__</string>
<string>-playwright-browser-dir</string><string>__BROWSER_DIR__</string>
</array>
<key>WorkingDirectory</key><string>__DATA_DIR__</string>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>
<key>StandardOutPath</key><string>__LOG_DIR__/server.log</string>
<key>StandardErrorPath</key><string>__LOG_DIR__/server.log</string>
</dict>
</plist>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>com.christ.ydisks-xianyu-helper.tray</string>
<key>ProgramArguments</key><array><string>__TRAY__</string></array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>
+64
View File
@@ -0,0 +1,64 @@
#!/bin/sh
set -eu
APP="/Applications/Ydisks Xianyu Helper.app"
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
SERVER="$APP/Contents/Helpers/xianyu-server"
TRAY="$APP/Contents/MacOS/xianyu-tray"
BROWSER_INSTALL="$APP/Contents/Helpers/browser-install"
CONSOLE_USER="$(stat -f '%Su' /dev/console)"
if [ "$CONSOLE_USER" = "root" ] || [ -z "$CONSOLE_USER" ]; then
echo "没有登录用户,跳过 LaunchAgent 和 Chromium 初始化;登录后请重新打开应用。"
exit 0
fi
UID_VALUE="$(id -u "$CONSOLE_USER")"
HOME_DIR="$(dscl . -read "/Users/$CONSOLE_USER" NFSHomeDirectory | awk '{print $2}')"
DATA_DIR="$HOME_DIR/Library/Application Support/YdisksXianyuHelper"
DRIVER_DIR="$DATA_DIR/playwright-driver"
BROWSER_DIR="$DATA_DIR/playwright-browsers"
LOG_DIR="$HOME_DIR/Library/Logs/YdisksXianyuHelper"
AGENT_DIR="$HOME_DIR/Library/LaunchAgents"
mkdir -p "$DATA_DIR" "$DRIVER_DIR" "$BROWSER_DIR" "$LOG_DIR" "$AGENT_DIR"
chown -R "$CONSOLE_USER" "$DATA_DIR" "$LOG_DIR" "$AGENT_DIR"
escape_sed() {
printf '%s' "$1" | sed 's/[&|]/\\&/g'
}
SERVER_ESCAPED="$(escape_sed "$SERVER")"
TRAY_ESCAPED="$(escape_sed "$TRAY")"
DATA_ESCAPED="$(escape_sed "$DATA_DIR")"
DRIVER_ESCAPED="$(escape_sed "$DRIVER_DIR")"
BROWSER_ESCAPED="$(escape_sed "$BROWSER_DIR")"
LOG_ESCAPED="$(escape_sed "$LOG_DIR")"
DATA_KEY_ESCAPED="$(escape_sed "$DATA_DIR/data-key")"
server_plist="$AGENT_DIR/com.christ.ydisks-xianyu-helper.server.plist"
tray_plist="$AGENT_DIR/com.christ.ydisks-xianyu-helper.tray.plist"
sed -e "s|__SERVER__|$SERVER_ESCAPED|g" \
-e "s|__DATA_DIR__|$DATA_ESCAPED|g" \
-e "s|__DATA_KEY__|$DATA_KEY_ESCAPED|g" \
-e "s|__DRIVER_DIR__|$DRIVER_ESCAPED|g" \
-e "s|__BROWSER_DIR__|$BROWSER_ESCAPED|g" \
-e "s|__LOG_DIR__|$LOG_ESCAPED|g" \
"$APP/Contents/Resources/com.christ.ydisks-xianyu-helper.server.plist.template" > "$server_plist"
sed -e "s|__TRAY__|$TRAY_ESCAPED|g" \
"$APP/Contents/Resources/com.christ.ydisks-xianyu-helper.tray.plist.template" > "$tray_plist"
chown "$CONSOLE_USER" "$server_plist" "$tray_plist"
chmod 0644 "$server_plist" "$tray_plist"
launchctl bootout "gui/$UID_VALUE/com.christ.ydisks-xianyu-helper.server" >/dev/null 2>&1 || true
launchctl bootout "gui/$UID_VALUE/com.christ.ydisks-xianyu-helper.tray" >/dev/null 2>&1 || true
launchctl asuser "$UID_VALUE" env HOME="$HOME_DIR" "$BROWSER_INSTALL" \
-driver-dir "$DRIVER_DIR" -browser-dir "$BROWSER_DIR" >/tmp/ydisks-xianyu-helper-browser-install.log 2>&1 || {
echo "Chromium 自动安装失败,详见 /tmp/ydisks-xianyu-helper-browser-install.log"
}
launchctl bootstrap "gui/$UID_VALUE" "$server_plist"
launchctl bootstrap "gui/$UID_VALUE" "$tray_plist"
launchctl kickstart -k "gui/$UID_VALUE/com.christ.ydisks-xianyu-helper.server"
launchctl kickstart -k "gui/$UID_VALUE/com.christ.ydisks-xianyu-helper.tray"