完善三平台安装包与服务控制流程

统一服务默认端口为 59188,完善 Windows 服务权限与 macOS LaunchAgent 管理。

实现 Windows 与 macOS 托盘状态机、服务启停等待、单实例保护、日志目录入口和退出前清理后台服务。

统一 Linux、Windows、macOS 与 Docker 的 Playwright Chromium runtime 构建流程,增加缓存、架构校验和 Linux 原生 runner,避免 QEMU。

完善 Windows、macOS、Linux 安装包及签名打包脚本,修正 Chromium 嵌入、服务注册和安装卸载流程。

同步 README、AGENTS、官网首页、Wiki 与前端开发文档,统一端口、初始化、服务、日志、托盘和安装说明。
This commit is contained in:
Christ committed 2026-08-12 20:53:53 +08:00
1 parent 94f4e070f6
commit 2df324647a
35 files changed
+1546 -214

No files matched your search

+70 -18
View File
@@ -18,12 +18,19 @@ env:
jobs:
linux:
name: Linux 安装包
name: Linux 安装包 (${{ matrix.arch }})
if: github.ref == 'refs/heads/codex/desktop-packaging'
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-24.04
playwright_platform: ubuntu24.04-x64
- arch: arm64
runner: ubuntu-24.04-arm
playwright_platform: ubuntu24.04-arm64
steps:
- name: 检出代码
uses: actions/checkout@v6
@@ -41,9 +48,6 @@ jobs:
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: 配置 QEMU
uses: docker/setup-qemu-action@v4
- name: 构建嵌入式前端
run: npm ci --prefix frontend && npm run build --prefix frontend
@@ -63,33 +67,62 @@ jobs:
uses: actions/cache/restore@v5
with:
path: dist/ydisks-xianyu-helper-linux-${{ matrix.arch }}/playwright-runtime
key: ydisks-playwright-runtime-v2-linux-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/main.go') }}
key: ydisks-playwright-runtime-v4-linux-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/main.go') }}
- name: 预下载 Linux Chromium runtime
- name: 在原生架构 runner 预下载 Linux Chromium runtime
if: steps.cache-linux-playwright.outputs.cache-hit != 'true'
env:
GOARCH: ${{ matrix.arch }}
PLAYWRIGHT_HOST_PLATFORM_OVERRIDE: ${{ matrix.playwright_platform }}
run: |
set -Eeuo pipefail
case "$(uname -m)" in
x86_64) runner_arch=amd64 ;;
aarch64|arm64) runner_arch=arm64 ;;
*) echo "不支持的 runner 架构:$(uname -m)" >&2; exit 1 ;;
esac
if [ "$runner_arch" != "$GOARCH" ]; then
echo "runner 架构 $runner_arch 与目标架构 $GOARCH 不一致,拒绝使用模拟器构建。" >&2
exit 1
fi
package_dir="dist/ydisks-xianyu-helper-linux-${GOARCH}"
runtime_dir="$package_dir/playwright-runtime/$GOARCH"
case "$GOARCH" in
amd64) playwright_platform="ubuntu20.04-x64" ;;
arm64) playwright_platform="ubuntu20.04-arm64" ;;
*) echo "不支持的 Linux 架构:$GOARCH" >&2; exit 1 ;;
esac
mkdir -p "$runtime_dir/playwright-driver" "$runtime_dir/playwright-browsers"
PLAYWRIGHT_HOST_PLATFORM_OVERRIDE="$playwright_platform" \
"$package_dir/browser-install" \
-driver-dir "$runtime_dir/playwright-driver" \
-browser-dir "$runtime_dir/playwright-browsers"
"$package_dir/browser-install" \
-driver-dir "$PWD/$runtime_dir/playwright-driver" \
-browser-dir "$PWD/$runtime_dir/playwright-browsers"
- name: 保存 Linux Chromium runtime 缓存
if: steps.cache-linux-playwright.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: dist/ydisks-xianyu-helper-linux-${{ matrix.arch }}/playwright-runtime
key: ${{ steps.cache-linux-playwright.outputs.cache-primary-key }}
key: ydisks-playwright-runtime-v4-linux-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/main.go') }}
- name: 校验 Linux Chromium runtime 架构
env:
GOARCH: ${{ matrix.arch }}
run: |
set -Eeuo pipefail
runtime_dir="dist/ydisks-xianyu-helper-linux-${GOARCH}/playwright-runtime/${GOARCH}"
node_path="$runtime_dir/playwright-driver/node"
test -x "$node_path"
"$node_path" --version
node_type="$(file -b "$node_path")"
case "$GOARCH:$node_type" in
amd64:*x86-64*) ;;
arm64:*aarch64*|arm64:*ARM64*) ;;
*) echo "Playwright driver 架构错误:$node_type" >&2; exit 1 ;;
esac
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
\( -name chrome -o -name headless_shell \) -perm -111 -print -quit)"
test -n "$chromium_path"
chromium_type="$(file -b "$chromium_path")"
case "$GOARCH:$chromium_type" in
amd64:*x86-64*) ;;
arm64:*aarch64*|arm64:*ARM64*) ;;
*) echo "Chromium 架构错误:$chromium_type" >&2; exit 1 ;;
esac
- name: 组装 Linux 安装目录
run: |
@@ -132,6 +165,22 @@ jobs:
shell: pwsh
run: npm ci --prefix frontend; npm run build --prefix frontend
- name: 验证 Windows 托盘逻辑与安装脚本
shell: pwsh
run: |
go test ./cmd/tray
$tokens = $null
$parseErrors = $null
[void][System.Management.Automation.Language.Parser]::ParseFile(
(Resolve-Path 'packaging/windows/service-control.ps1'),
[ref]$tokens,
[ref]$parseErrors
)
if ($parseErrors.Count -gt 0) {
$parseErrors | ForEach-Object { Write-Error $_.Message }
throw 'Windows 服务安装脚本语法检查失败'
}
- name: 编译 Windows 桌面程序
shell: pwsh
run: |
@@ -245,6 +294,9 @@ jobs:
- name: 构建嵌入式前端
run: npm ci --prefix frontend && npm run build --prefix frontend
- name: 验证 macOS 托盘逻辑
run: go test ./cmd/tray
- name: 编译 macOS 桌面程序
run: |
mkdir -p dist/macos/arm64 dist/macos/amd64
+116 -19
View File
@@ -16,15 +16,38 @@ concurrency:
cancel-in-progress: true
jobs:
publish:
name: 发布多架构镜像
runs-on: ubuntu-latest
build:
name: 构建镜像 (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
platform: linux/amd64
- arch: arm64
runner: ubuntu-24.04-arm
platform: linux/arm64
steps:
- name: 检出代码
uses: actions/checkout@v6
- name: 配置 QEMU
uses: docker/setup-qemu-action@v4
- name: 校验 runner 原生架构
shell: bash
env:
EXPECTED_ARCH: ${{ matrix.arch }}
run: |
set -Eeuo pipefail
case "$(uname -m)" in
x86_64) actual_arch=amd64 ;;
aarch64|arm64) actual_arch=arm64 ;;
*) echo "不支持的 runner 架构:$(uname -m)" >&2; exit 1 ;;
esac
if [ "$actual_arch" != "$EXPECTED_ARCH" ]; then
echo "runner 架构 $actual_arch 与目标架构 $EXPECTED_ARCH 不一致,拒绝使用模拟器构建。" >&2
exit 1
fi
- name: 配置 Docker Buildx
uses: docker/setup-buildx-action@v4
@@ -41,6 +64,63 @@ jobs:
shell: bash
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: 构建并推送原生架构摘要
id: build
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile.debian13
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=ydisks-docker-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=ydisks-docker-${{ matrix.arch }}
provenance: mode=max
sbom: true
- name: 保存镜像摘要
shell: bash
env:
IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -Eeuo pipefail
mkdir -p dist/digests
touch "dist/digests/${IMAGE_DIGEST#sha256:}"
- name: 上传镜像摘要
uses: actions/upload-artifact@v7
with:
name: ydisks-docker-digest-${{ matrix.arch }}
path: dist/digests/*
if-no-files-found: error
retention-days: 1
publish:
name: 合并多架构镜像
needs: build
runs-on: ubuntu-24.04
steps:
- name: 配置 Docker Buildx
uses: docker/setup-buildx-action@v4
- name: 下载镜像摘要
uses: actions/download-artifact@v8
with:
pattern: ydisks-docker-digest-*
path: dist/digests
merge-multiple: true
- name: 登录 GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 生成小写镜像名称
id: image
shell: bash
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: 生成镜像标签
id: meta
uses: docker/metadata-action@v6
@@ -54,17 +134,34 @@ jobs:
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=alpha,enable=${{ github.ref == 'refs/heads/codex/desktop-packaging' }}
- name: 构建并推送镜像
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile.debian13
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Dockerfile 中的 Chromium 下载层也由 GitHub Actions 主机缓存。
cache-from: type=gha,scope=ydisks-docker
cache-to: type=gha,mode=max,scope=ydisks-docker
provenance: mode=max
sbom: true
- name: 创建并推送多架构 manifest
shell: bash
env:
IMAGE_NAME: ${{ steps.image.outputs.name }}
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
run: |
set -Eeuo pipefail
mapfile -t digest_files < <(find dist/digests -maxdepth 1 -type f -print | sort)
if [ "${#digest_files[@]}" -ne 2 ]; then
echo "预期 2 个镜像摘要,实际 ${#digest_files[@]} 个。" >&2
exit 1
fi
digest_args=()
for digest_file in "${digest_files[@]}"; do
digest_args+=("$IMAGE_NAME@sha256:$(basename "$digest_file")")
done
tag_args=()
while IFS= read -r tag; do
[ -n "$tag" ] && tag_args+=(--tag "$tag")
done <<< "$IMAGE_TAGS"
docker buildx imagetools create "${tag_args[@]}" "${digest_args[@]}"
- name: 检查多架构 manifest
shell: bash
env:
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
run: |
set -Eeuo pipefail
first_tag="$(printf '%s\n' "$IMAGE_TAGS" | sed -n '/./{p;q;}')"
test -n "$first_tag"
docker buildx imagetools inspect "$first_tag"