完善 Docker 发布与桌面安装包流水线
- 固定 Docker 与测试镜像使用 Node.js 24 trixie slim 基础镜像。 - 安装 Chromium 所需系统运行库,并清理 apt 索引、缓存和临时文件,降低最终镜像体积。 - 增加 Chromium 实际启动、服务健康检查以及 Go 和前端测试门禁,门禁通过后才发布镜像标签。 - 修复 v1.2.3 版本标签触发,自动构建版本镜像、各平台安装包并创建 GitHub Release。 - 完善版本产物校验、SHA256SUMS 校验和以及正式版本标签规则。 - 将 Linux、Windows、macOS 和 Docker 的 Playwright runtime 缓存改为独立恢复与立即保存。 - 修复 Chromium runtime 校验中的绝对路径问题,并补充平台与安装器源码缓存键。 - 同步更新发布文档、打包规范和前端路由测试断言。
This commit is contained in:
1 parent
70e03a8523
commit
d36c357bab
8 files changed
+280
-42
No files matched your search
@@ -5,6 +5,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- codex/desktop-packaging
|
- codex/desktop-packaging
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -14,14 +16,35 @@ concurrency:
|
|||||||
group: desktop-cd-${{ github.ref }}
|
group: desktop-cd-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
|
||||||
APP_VERSION: 0.0.0-${{ github.run_number }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
prepare:
|
||||||
|
name: 准备发布版本
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
outputs:
|
||||||
|
app_version: ${{ steps.version.outputs.app_version }}
|
||||||
|
steps:
|
||||||
|
- name: 解析并校验版本号
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||||
|
if [[ ! "$GITHUB_REF_NAME" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||||
|
echo "版本标签必须符合 v1.2.3 格式:$GITHUB_REF_NAME" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
app_version="${GITHUB_REF_NAME#v}"
|
||||||
|
else
|
||||||
|
app_version="0.0.0-${GITHUB_RUN_NUMBER}"
|
||||||
|
fi
|
||||||
|
echo "app_version=$app_version" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
name: Linux 安装包 (${{ matrix.arch }})
|
name: Linux 安装包 (${{ matrix.arch }})
|
||||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/codex/desktop-packaging'
|
needs: prepare
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
|
env:
|
||||||
|
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -45,7 +68,7 @@ jobs:
|
|||||||
- name: 配置 Node.js
|
- name: 配置 Node.js
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 24
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: frontend/package-lock.json
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
@@ -63,12 +86,12 @@ jobs:
|
|||||||
go build -trimpath -ldflags='-s -w' -o "$package_dir/xianyu-server" ./cmd/server
|
go build -trimpath -ldflags='-s -w' -o "$package_dir/xianyu-server" ./cmd/server
|
||||||
go build -trimpath -ldflags='-s -w' -o "$package_dir/browser-install" ./cmd/browser-install
|
go build -trimpath -ldflags='-s -w' -o "$package_dir/browser-install" ./cmd/browser-install
|
||||||
|
|
||||||
- name: 缓存 Linux Chromium runtime
|
- name: 恢复 Linux Chromium runtime 缓存
|
||||||
id: cache-linux-playwright
|
id: cache-linux-playwright
|
||||||
uses: actions/cache@v5
|
uses: actions/cache/restore@v5
|
||||||
with:
|
with:
|
||||||
path: dist/ydisks-xianyu-helper-linux-${{ matrix.arch }}/playwright-runtime
|
path: dist/ydisks-xianyu-helper-linux-${{ matrix.arch }}/playwright-runtime
|
||||||
key: ydisks-playwright-runtime-v6-linux-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum') }}
|
key: ydisks-playwright-runtime-v6-linux-${{ matrix.arch }}-${{ matrix.playwright_platform }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||||
|
|
||||||
- name: 在原生架构 runner 预下载 Linux Chromium runtime
|
- name: 在原生架构 runner 预下载 Linux Chromium runtime
|
||||||
if: steps.cache-linux-playwright.outputs.cache-hit != 'true'
|
if: steps.cache-linux-playwright.outputs.cache-hit != 'true'
|
||||||
@@ -111,8 +134,8 @@ jobs:
|
|||||||
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
|
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
|
||||||
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
|
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
|
||||||
test -n "$chromium_path"
|
test -n "$chromium_path"
|
||||||
chromium_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
chromium_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||||
headless_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
headless_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||||
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
||||||
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
||||||
chromium_type="$(file -b "$chromium_path")"
|
chromium_type="$(file -b "$chromium_path")"
|
||||||
@@ -122,6 +145,13 @@ jobs:
|
|||||||
*) echo "Chromium 架构错误:$chromium_type" >&2; exit 1 ;;
|
*) echo "Chromium 架构错误:$chromium_type" >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
- 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 }}
|
||||||
|
|
||||||
- name: 组装 Linux 安装目录
|
- name: 组装 Linux 安装目录
|
||||||
run: |
|
run: |
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
@@ -140,8 +170,10 @@ jobs:
|
|||||||
|
|
||||||
windows:
|
windows:
|
||||||
name: Windows 安装包
|
name: Windows 安装包
|
||||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/codex/desktop-packaging'
|
needs: prepare
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
@@ -155,7 +187,7 @@ jobs:
|
|||||||
- name: 配置 Node.js
|
- name: 配置 Node.js
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 24
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: frontend/package-lock.json
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
@@ -187,12 +219,12 @@ jobs:
|
|||||||
go build -trimpath -ldflags "-s -w" -o dist/windows/browser-install.exe ./cmd/browser-install
|
go build -trimpath -ldflags "-s -w" -o dist/windows/browser-install.exe ./cmd/browser-install
|
||||||
go build -trimpath -ldflags "-s -w -H=windowsgui" -o dist/windows/xianyu-tray.exe ./cmd/tray
|
go build -trimpath -ldflags "-s -w -H=windowsgui" -o dist/windows/xianyu-tray.exe ./cmd/tray
|
||||||
|
|
||||||
- name: 缓存 Windows Chromium runtime
|
- name: 恢复 Windows Chromium runtime 缓存
|
||||||
id: cache-windows-playwright
|
id: cache-windows-playwright
|
||||||
uses: actions/cache@v5
|
uses: actions/cache/restore@v5
|
||||||
with:
|
with:
|
||||||
path: dist/windows/playwright-runtime/amd64
|
path: dist/windows/playwright-runtime/amd64
|
||||||
key: ydisks-playwright-runtime-v6-windows-amd64-${{ hashFiles('go.mod', 'go.sum') }}
|
key: ydisks-playwright-runtime-v6-windows-amd64-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||||
|
|
||||||
- name: 预下载 Windows Chromium runtime
|
- name: 预下载 Windows Chromium runtime
|
||||||
if: steps.cache-windows-playwright.outputs.cache-hit != 'true'
|
if: steps.cache-windows-playwright.outputs.cache-hit != 'true'
|
||||||
@@ -223,6 +255,13 @@ jobs:
|
|||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
if ($null -eq $chromium) { throw 'Windows Chromium runtime 缺少 Chromium 可执行文件' }
|
if ($null -eq $chromium) { throw 'Windows Chromium runtime 缺少 Chromium 可执行文件' }
|
||||||
|
|
||||||
|
- name: 保存 Windows Chromium runtime 缓存
|
||||||
|
if: steps.cache-windows-playwright.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache/save@v5
|
||||||
|
with:
|
||||||
|
path: dist/windows/playwright-runtime/amd64
|
||||||
|
key: ${{ steps.cache-windows-playwright.outputs.cache-primary-key }}
|
||||||
|
|
||||||
- name: 导入 Windows 签名证书
|
- name: 导入 Windows 签名证书
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
env:
|
env:
|
||||||
@@ -288,8 +327,10 @@ jobs:
|
|||||||
|
|
||||||
macos:
|
macos:
|
||||||
name: macOS 安装包
|
name: macOS 安装包
|
||||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/codex/desktop-packaging'
|
needs: prepare
|
||||||
runs-on: macos-14
|
runs-on: macos-14
|
||||||
|
env:
|
||||||
|
APP_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
@@ -303,7 +344,7 @@ jobs:
|
|||||||
- name: 配置 Node.js
|
- name: 配置 Node.js
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 24
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: frontend/package-lock.json
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
@@ -329,7 +370,7 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
dist/macos/playwright-runtime/arm64
|
dist/macos/playwright-runtime/arm64
|
||||||
dist/macos/playwright-runtime/amd64
|
dist/macos/playwright-runtime/amd64
|
||||||
key: ydisks-playwright-runtime-v6-macos-universal-${{ hashFiles('go.mod', 'go.sum') }}
|
key: ydisks-playwright-runtime-v6-macos-mac14-universal-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||||
|
|
||||||
- name: 预下载 macOS Chromium runtime
|
- name: 预下载 macOS Chromium runtime
|
||||||
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
|
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
|
||||||
@@ -348,6 +389,34 @@ jobs:
|
|||||||
-driver-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-driver" \
|
-driver-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-driver" \
|
||||||
-browser-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-browsers"
|
-browser-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-browsers"
|
||||||
|
|
||||||
|
- name: 校验 macOS Chromium runtime
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
for runtime_arch in arm64 amd64; do
|
||||||
|
runtime_dir="dist/macos/playwright-runtime/$runtime_arch"
|
||||||
|
node_path="$runtime_dir/playwright-driver/node"
|
||||||
|
spec_path="$PWD/$runtime_dir/playwright-driver/package/browsers.json"
|
||||||
|
test -x "$node_path"
|
||||||
|
test -f "$runtime_dir/playwright-driver/package/cli.js"
|
||||||
|
test -f "$spec_path"
|
||||||
|
chromium_revision="$(RUNTIME_SPEC="$spec_path" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||||
|
headless_revision="$(RUNTIME_SPEC="$spec_path" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||||
|
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
||||||
|
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
||||||
|
chromium_path="$(find "$runtime_dir/playwright-browsers/chromium-$chromium_revision" -type f -path '*/Contents/MacOS/Google Chrome for Testing' -print -quit)"
|
||||||
|
headless_path="$(find "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision" -type f -name chrome-headless-shell -print -quit)"
|
||||||
|
test -n "$chromium_path"
|
||||||
|
test -n "$headless_path"
|
||||||
|
node_type="$(file -b "$node_path")"
|
||||||
|
chromium_type="$(file -b "$chromium_path")"
|
||||||
|
headless_type="$(file -b "$headless_path")"
|
||||||
|
case "$runtime_arch:$node_type:$chromium_type:$headless_type" in
|
||||||
|
arm64:*arm64*:*arm64*:*arm64*) ;;
|
||||||
|
amd64:*x86_64*:*x86_64*:*x86_64*) ;;
|
||||||
|
*) echo "macOS Playwright runtime 架构错误:$runtime_arch / $node_type / $chromium_type / $headless_type" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
- name: 保存 macOS Chromium runtime 缓存
|
- name: 保存 macOS Chromium runtime 缓存
|
||||||
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
|
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
|
||||||
uses: actions/cache/save@v5
|
uses: actions/cache/save@v5
|
||||||
@@ -414,3 +483,54 @@ jobs:
|
|||||||
name: ydisks-xianyu-helper-macos-amd64-${{ env.APP_VERSION }}
|
name: ydisks-xianyu-helper-macos-amd64-${{ env.APP_VERSION }}
|
||||||
path: dist/macos/Ydisks-Xianyu-Helper-${{ env.APP_VERSION }}-amd64.pkg
|
path: dist/macos/Ydisks-Xianyu-Helper-${{ env.APP_VERSION }}-amd64.pkg
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: 发布 GitHub Release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- macos
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: 下载全部平台安装包
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
pattern: ydisks-xianyu-helper-*
|
||||||
|
path: dist/release
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: 校验 Release 文件
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
test -f "dist/release/ydisks-xianyu-helper-linux-amd64-${{ needs.prepare.outputs.app_version }}.tar.gz"
|
||||||
|
test -f "dist/release/ydisks-xianyu-helper-linux-arm64-${{ needs.prepare.outputs.app_version }}.tar.gz"
|
||||||
|
test -f "dist/release/Ydisks-Xianyu-Helper-Setup.exe"
|
||||||
|
test -f "dist/release/Ydisks-Xianyu-Helper-${{ needs.prepare.outputs.app_version }}-binaries.zip"
|
||||||
|
test -f "dist/release/Ydisks-Xianyu-Helper-${{ needs.prepare.outputs.app_version }}-arm64.pkg"
|
||||||
|
test -f "dist/release/Ydisks-Xianyu-Helper-${{ needs.prepare.outputs.app_version }}-amd64.pkg"
|
||||||
|
(
|
||||||
|
cd dist/release
|
||||||
|
sha256sum * > SHA256SUMS
|
||||||
|
)
|
||||||
|
|
||||||
|
- name: 创建或更新 GitHub Release
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
RELEASE_VERSION: ${{ needs.prepare.outputs.app_version }}
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
mapfile -t release_files < <(find dist/release -maxdepth 1 -type f -print | sort)
|
||||||
|
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
|
||||||
|
gh release upload "$GITHUB_REF_NAME" "${release_files[@]}" --clobber
|
||||||
|
else
|
||||||
|
gh release create "$GITHUB_REF_NAME" "${release_files[@]}" \
|
||||||
|
--verify-tag \
|
||||||
|
--generate-notes \
|
||||||
|
--title "Ydisks 闲鱼助手 $RELEASE_VERSION"
|
||||||
|
fi
|
||||||
@@ -5,6 +5,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- codex/desktop-packaging
|
- codex/desktop-packaging
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -16,8 +18,53 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
verify:
|
||||||
|
name: Docker 发布测试门禁
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: 校验版本标签
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo "版本标签必须符合 v1.2.3 格式:$GITHUB_REF_NAME" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 检出代码
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: 配置 Go
|
||||||
|
uses: actions/setup-go@v7
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: 配置 Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
|
- name: 验证前端
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
npm ci --prefix frontend
|
||||||
|
npm run typecheck --prefix frontend
|
||||||
|
npm test --prefix frontend
|
||||||
|
npm run build --prefix frontend
|
||||||
|
|
||||||
|
- name: 验证 Go 服务
|
||||||
|
run: |
|
||||||
|
go vet ./...
|
||||||
|
go test ./...
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: 构建镜像 (${{ matrix.arch }})
|
name: 构建镜像 (${{ matrix.arch }})
|
||||||
|
needs: verify
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -57,12 +104,17 @@ jobs:
|
|||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: 缓存 Docker Chromium runtime
|
- name: 配置 Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: 恢复 Docker Chromium runtime 缓存
|
||||||
id: cache-docker-playwright
|
id: cache-docker-playwright
|
||||||
uses: actions/cache@v5
|
uses: actions/cache/restore@v5
|
||||||
with:
|
with:
|
||||||
path: .docker/playwright-runtime/${{ matrix.arch }}
|
path: .docker/playwright-runtime/${{ matrix.arch }}
|
||||||
key: ydisks-playwright-runtime-v6-docker-${{ matrix.arch }}-${{ hashFiles('go.mod', 'go.sum') }}
|
key: ydisks-playwright-runtime-v6-docker-${{ matrix.arch }}-${{ matrix.playwright_platform }}-${{ hashFiles('go.mod', 'go.sum', 'cmd/browser-install/**') }}
|
||||||
|
|
||||||
- name: 准备 Docker Chromium runtime
|
- name: 准备 Docker Chromium runtime
|
||||||
if: steps.cache-docker-playwright.outputs.cache-hit != 'true'
|
if: steps.cache-docker-playwright.outputs.cache-hit != 'true'
|
||||||
@@ -92,11 +144,18 @@ jobs:
|
|||||||
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
|
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
|
||||||
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
|
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
|
||||||
test -n "$chromium_path"
|
test -n "$chromium_path"
|
||||||
chromium_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
chromium_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium").revision)')"
|
||||||
headless_revision="$(RUNTIME_SPEC="$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
headless_revision="$(RUNTIME_SPEC="$PWD/$runtime_dir/playwright-driver/package/browsers.json" node -e 'const b=require(process.env.RUNTIME_SPEC).browsers; console.log(b.find(x=>x.name==="chromium-headless-shell").revision)')"
|
||||||
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
test -d "$runtime_dir/playwright-browsers/chromium-$chromium_revision"
|
||||||
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
test -d "$runtime_dir/playwright-browsers/chromium_headless_shell-$headless_revision"
|
||||||
|
|
||||||
|
- name: 保存 Docker Chromium runtime 缓存
|
||||||
|
if: steps.cache-docker-playwright.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache/save@v5
|
||||||
|
with:
|
||||||
|
path: .docker/playwright-runtime/${{ matrix.arch }}
|
||||||
|
key: ${{ steps.cache-docker-playwright.outputs.cache-primary-key }}
|
||||||
|
|
||||||
- name: 配置 Docker Buildx
|
- name: 配置 Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
@@ -125,6 +184,48 @@ jobs:
|
|||||||
provenance: mode=max
|
provenance: mode=max
|
||||||
sbom: true
|
sbom: true
|
||||||
|
|
||||||
|
- name: 验证待发布镜像中的 Chromium 与服务
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ${{ steps.image.outputs.name }}
|
||||||
|
IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
image_ref="$IMAGE_NAME@$IMAGE_DIGEST"
|
||||||
|
docker pull "$image_ref"
|
||||||
|
|
||||||
|
docker run --rm --entrypoint sh "$image_ref" -ec '
|
||||||
|
chromium_path="$(find /ms-playwright/chromium-* -type f \
|
||||||
|
-name chrome -perm -111 -print -quit)"
|
||||||
|
test -n "$chromium_path"
|
||||||
|
timeout 45 "$chromium_path" \
|
||||||
|
--headless --no-sandbox --disable-gpu --disable-dev-shm-usage \
|
||||||
|
--dump-dom about:blank | grep -q "<html"
|
||||||
|
'
|
||||||
|
|
||||||
|
container_id="$(docker run -d -p 127.0.0.1::59188 "$image_ref")"
|
||||||
|
cleanup() {
|
||||||
|
docker logs "$container_id" || true
|
||||||
|
docker rm -f "$container_id" >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
host_port="$(docker port "$container_id" 59188/tcp | sed -n 's/.*://p' | head -n 1)"
|
||||||
|
test -n "$host_port"
|
||||||
|
for attempt in $(seq 1 60); do
|
||||||
|
if health="$(curl --fail --silent --show-error "http://127.0.0.1:$host_port/health" 2>/dev/null)"; then
|
||||||
|
printf '%s' "$health" | grep -q '"status":"ok"'
|
||||||
|
printf '%s' "$health" | grep -q '"database":"ok"'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if ! docker inspect -f '{{.State.Running}}' "$container_id" | grep -q true; then
|
||||||
|
echo '待发布镜像中的服务提前退出。' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo '待发布镜像未能在 60 秒内通过健康检查。' >&2
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: 保存镜像摘要
|
- name: 保存镜像摘要
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
@@ -175,6 +276,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ steps.image.outputs.name }}
|
images: ${{ steps.image.outputs.name }}
|
||||||
tags: |
|
tags: |
|
||||||
|
type=ref,event=tag
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=sha,format=long
|
type=sha,format=long
|
||||||
|
|||||||
@@ -107,11 +107,15 @@ packages explicitly bind the server to `127.0.0.1:59188` and keep the server and
|
|||||||
|
|
||||||
All desktop packages contain the matching Playwright driver, Chromium and headless shell. Do not add a
|
All desktop packages contain the matching Playwright driver, Chromium and headless shell. Do not add a
|
||||||
Debian Chromium package or download a second browser during installation. The Docker final image uses
|
Debian Chromium package or download a second browser during installation. The Docker final image uses
|
||||||
`node:latest`, copies the cached runtime prepared by CI, and does not run `apt-get update`. The desktop CI workflow
|
`node:24-trixie-slim`, copies the cached runtime prepared by CI, installs only the Chromium system libraries
|
||||||
runs on `main` and `codex/desktop-packaging`; Linux amd64 and arm64 jobs use native GitHub-hosted runners and
|
through the bundled Playwright driver, and clears apt indexes and temporary caches in the same image layer.
|
||||||
|
The desktop CI workflow runs on `main`, `codex/desktop-packaging`, and `v*.*.*` version tags; Linux amd64 and
|
||||||
|
arm64 jobs use native GitHub-hosted runners and
|
||||||
must not use QEMU or cross-architecture emulation. Docker publishing also builds each architecture on its native
|
must not use QEMU or cross-architecture emulation. Docker publishing also builds each architecture on its native
|
||||||
runner and publishes `main` and `latest` from `main`, `desktop-packaging` and `alpha` from
|
runner and publishes `main` and `latest` from `main`, `desktop-packaging` and `alpha` from
|
||||||
`codex/desktop-packaging`.
|
`codex/desktop-packaging`, and semantic version tags from `v*.*.*`. Version tags also create a GitHub Release
|
||||||
|
containing all platform packages and SHA-256 checksums. Never publish a Docker manifest until Go/frontend tests,
|
||||||
|
an actual Chromium launch, and the packaged server health check have passed for every architecture.
|
||||||
|
|
||||||
The tray state machine is shared by Windows and macOS: it serializes actions, shows transition states,
|
The tray state machine is shared by Windows and macOS: it serializes actions, shows transition states,
|
||||||
waits for a healthy `/health` response after start/restart, waits for the endpoint to become unreachable
|
waits for a healthy `/health` response after start/restart, waits for the endpoint to become unreachable
|
||||||
|
|||||||
+10
-4
@@ -1,6 +1,6 @@
|
|||||||
# syntax=docker/dockerfile:1.7
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM node:latest AS frontend
|
FROM --platform=$BUILDPLATFORM node:24-trixie-slim AS frontend
|
||||||
WORKDIR /src/frontend
|
WORKDIR /src/frontend
|
||||||
COPY frontend/package*.json ./
|
COPY frontend/package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
@@ -30,7 +30,7 @@ RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/browser-install-ho
|
|||||||
|
|
||||||
# Docker CI 会把与独立安装包相同的目标架构 runtime 放到
|
# Docker CI 会把与独立安装包相同的目标架构 runtime 放到
|
||||||
# .docker/playwright-runtime,构建时直接复制,不在 Dockerfile 内重复下载浏览器。
|
# .docker/playwright-runtime,构建时直接复制,不在 Dockerfile 内重复下载浏览器。
|
||||||
FROM --platform=$BUILDPLATFORM node:latest AS playwright-runtime
|
FROM --platform=$BUILDPLATFORM node:24-trixie-slim AS playwright-runtime
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go
|
ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go
|
||||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||||
@@ -63,7 +63,7 @@ RUN set -eux; \
|
|||||||
test -d "/ms-playwright/chromium_headless_shell-$headless_revision"; \
|
test -d "/ms-playwright/chromium_headless_shell-$headless_revision"; \
|
||||||
find /ms-playwright -type f -perm -111 \( -name chrome -o -name chrome-headless-shell -o -name headless_shell \) -print -quit | grep -q .
|
find /ms-playwright -type f -perm -111 \( -name chrome -o -name chrome-headless-shell -o -name headless_shell \) -print -quit | grep -q .
|
||||||
|
|
||||||
FROM node:latest AS runtime
|
FROM node:24-trixie-slim AS runtime
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
ENV BROWSER_HEADLESS=true
|
ENV BROWSER_HEADLESS=true
|
||||||
ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go
|
ENV PLAYWRIGHT_DRIVER_PATH=/ms-playwright-go
|
||||||
@@ -76,6 +76,12 @@ COPY --from=backend /out/xianyu-dbseed /app/xianyu-dbseed
|
|||||||
COPY --from=backend /out/xianyu-dbverify /app/xianyu-dbverify
|
COPY --from=backend /out/xianyu-dbverify /app/xianyu-dbverify
|
||||||
COPY --from=playwright-runtime /ms-playwright-go /ms-playwright-go
|
COPY --from=playwright-runtime /ms-playwright-go /ms-playwright-go
|
||||||
COPY --from=playwright-runtime /ms-playwright /ms-playwright
|
COPY --from=playwright-runtime /ms-playwright /ms-playwright
|
||||||
RUN mkdir -p /app/data /app/browser_data
|
# 浏览器文件本身不包含 Linux 动态链接库。使用与 runtime 同捆的 Playwright
|
||||||
|
# driver 只安装 Chromium 所需系统依赖,并在同一镜像层清理 apt/npm/临时缓存。
|
||||||
|
RUN set -eux; \
|
||||||
|
node /ms-playwright-go/package/cli.js install-deps chromium; \
|
||||||
|
apt-get clean; \
|
||||||
|
rm -rf /var/lib/apt/lists/* /var/cache/apt/* /root/.cache /tmp/* /var/tmp/*; \
|
||||||
|
mkdir -p /app/data /app/browser_data
|
||||||
EXPOSE 59188
|
EXPOSE 59188
|
||||||
CMD ["/app/xianyu-server", "-addr", ":59188"]
|
CMD ["/app/xianyu-server", "-addr", ":59188"]
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
FROM alpine:3.22 AS sqlite-tools
|
FROM alpine:3.22 AS sqlite-tools
|
||||||
RUN apk add --no-cache sqlite
|
RUN apk add --no-cache sqlite
|
||||||
|
|
||||||
FROM node:latest AS frontend-assets
|
FROM node:24-trixie-slim AS frontend-assets
|
||||||
WORKDIR /src/frontend
|
WORKDIR /src/frontend
|
||||||
COPY frontend/package*.json ./
|
COPY frontend/package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
@@ -24,7 +24,7 @@ COPY . .
|
|||||||
COPY --from=frontend-assets /src/internal/webui/static ./internal/webui/static
|
COPY --from=frontend-assets /src/internal/webui/static ./internal/webui/static
|
||||||
CMD ["golangci-lint", "run", "./..."]
|
CMD ["golangci-lint", "run", "./..."]
|
||||||
|
|
||||||
FROM node:latest AS frontend-test
|
FROM node:24-trixie-slim AS frontend-test
|
||||||
WORKDIR /src/frontend
|
WORKDIR /src/frontend
|
||||||
COPY frontend/package*.json ./
|
COPY frontend/package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ docker compose up -d
|
|||||||
环境要求:
|
环境要求:
|
||||||
|
|
||||||
- Go 1.26.4 或兼容版本
|
- Go 1.26.4 或兼容版本
|
||||||
- Node.js 22 与 npm
|
- Node.js 24 与 npm
|
||||||
- Chromium 运行所需的系统依赖
|
- Chromium 运行所需的系统依赖
|
||||||
- 默认可直接使用 SQLite,无需额外数据库服务
|
- 默认可直接使用 SQLite,无需额外数据库服务
|
||||||
|
|
||||||
@@ -208,8 +208,10 @@ Windows 和 macOS 托盘启动时会自动启动后台服务,并显示检查
|
|||||||
`/var/log/ydisks-xianyu-helper/server.log`,也可以使用
|
`/var/log/ydisks-xianyu-helper/server.log`,也可以使用
|
||||||
`journalctl -u ydisks-xianyu-helper.service` 查看。
|
`journalctl -u ydisks-xianyu-helper.service` 查看。
|
||||||
|
|
||||||
桌面端安装包由 GitHub Actions 工作流在 `main` 和 `codex/desktop-packaging` 分支构建:Linux 上传
|
桌面端安装包由 GitHub Actions 工作流在 `main`、`codex/desktop-packaging` 分支以及 `v1.2.3`
|
||||||
amd64/arm64 tar 包,Windows 上传安装器,macOS 分别上传 arm64 和 amd64 安装包。Windows
|
格式的版本标签上构建:Linux 上传 amd64/arm64 tar 包,Windows 上传安装器,macOS 分别上传
|
||||||
|
arm64 和 amd64 安装包。版本标签构建全部成功后,会自动创建 GitHub Release,上传各平台安装包
|
||||||
|
及 `SHA256SUMS`。Windows
|
||||||
和 macOS 安装包使用工作流中配置的固定签名证书签名;未配置对应 GitHub Secrets 时,签名
|
和 macOS 安装包使用工作流中配置的固定签名证书签名;未配置对应 GitHub Secrets 时,签名
|
||||||
步骤会失败,不会生成可分发的安装包。
|
步骤会失败,不会生成可分发的安装包。
|
||||||
|
|
||||||
@@ -409,11 +411,13 @@ ARM64 Linux 拉取 arm64,不需要手动设置 `platform`。
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `main` 分支 | `main`、`latest`、`sha-<完整提交号>` |
|
| `main` 分支 | `main`、`latest`、`sha-<完整提交号>` |
|
||||||
| `codex/desktop-packaging` 分支 | `alpha`、`desktop-packaging`、`sha-<完整提交号>` |
|
| `codex/desktop-packaging` 分支 | `alpha`、`desktop-packaging`、`sha-<完整提交号>` |
|
||||||
| `v1.2.3` 标签 | `1.2.3`、`1.2`、`sha-<完整提交号>` |
|
| `v1.2.3` 标签 | `v1.2.3`、`1.2.3`、`1.2`、`sha-<完整提交号>` |
|
||||||
|
|
||||||
当前 Docker 发布工作流会在 `main` 分支发布 `main` 和 `latest` 正式镜像,并在
|
当前 Docker 发布工作流会在 `main` 分支发布 `main` 和 `latest` 正式镜像,并在
|
||||||
`codex/desktop-packaging` 分支发布 `desktop-packaging` 和 `alpha` 标签用于验收;其他开发分支
|
`codex/desktop-packaging` 分支发布 `desktop-packaging` 和 `alpha` 标签用于验收;其他开发分支
|
||||||
不会自动生成 GHCR 标签。
|
不会自动生成 GHCR 标签。推送 `v1.2.3` 格式的 Git 标签会同时触发版本 Docker 镜像和 GitHub
|
||||||
|
Release。所有 Docker 发布都必须先通过 Go/前端测试,再对每个原生架构镜像实际启动 Chromium
|
||||||
|
和服务并通过 `/health` 检查,之后才会生成 `latest`、分支或版本 manifest。
|
||||||
|
|
||||||
生产环境建议使用明确的版本标签或 SHA 标签,避免上游更新导致未经验证的自动升级。
|
生产环境建议使用明确的版本标签或 SHA 标签,避免上游更新导致未经验证的自动升级。
|
||||||
|
|
||||||
@@ -650,8 +654,9 @@ go run ./cmd/server -init-admin -db data/xianyu_data.db -admin-password '新密
|
|||||||
### Chromium 或 Playwright 初始化失败
|
### Chromium 或 Playwright 初始化失败
|
||||||
|
|
||||||
- Docker 部署优先使用项目提供的镜像,镜像在构建阶段已下载并校验匹配架构的 Chromium runtime;
|
- Docker 部署优先使用项目提供的镜像,镜像在构建阶段已下载并校验匹配架构的 Chromium runtime;
|
||||||
Docker CI 优先复用 GitHub Actions 缓存,不依赖 Debian 仓库中的 `chromium` 包,也不会在最终镜像
|
Docker CI 优先复用 GitHub Actions 缓存,不依赖 Debian 仓库中的 `chromium` 包。最终镜像基于
|
||||||
构建阶段执行 `apt-get update`。
|
固定的 Node.js 24 slim 镜像,只通过 Playwright 安装 Chromium 所需动态库,并在同一镜像层清理
|
||||||
|
apt 索引和临时缓存;发布前会实际启动 Chromium 和服务进行门禁验证。
|
||||||
- 独立安装包在 CI 构建阶段下载对应架构的 Playwright driver 和 Chromium;Linux 安装时只
|
- 独立安装包在 CI 构建阶段下载对应架构的 Playwright driver 和 Chromium;Linux 安装时只
|
||||||
安装系统库,不需要再次下载浏览器。
|
安装系统库,不需要再次下载浏览器。
|
||||||
- 源码运行时确认系统允许下载 Playwright 驱动和 Chromium。
|
- 源码运行时确认系统允许下载 Playwright 驱动和 Chromium。
|
||||||
|
|||||||
+3
-2
@@ -30,8 +30,9 @@ Docker 中的自动续期会使用容器内 Chromium 检测到的 Linux 原生
|
|||||||
|
|
||||||
独立安装包与 Docker 使用同一套 Playwright Chromium 版本来源:Chromium、headless shell 和
|
独立安装包与 Docker 使用同一套 Playwright Chromium 版本来源:Chromium、headless shell 和
|
||||||
Playwright driver 都在构建阶段下载并放入包内,不使用 Debian 仓库的 Chromium。Docker CI 会优先
|
Playwright driver 都在构建阶段下载并放入包内,不使用 Debian 仓库的 Chromium。Docker CI 会优先
|
||||||
复用架构专属的 GitHub Actions runtime 缓存,Dockerfile 最终使用 `node:latest` 运行时,不执行
|
复用架构专属的 GitHub Actions runtime 缓存,Dockerfile 最终使用固定的 Node.js 24 slim 运行时,
|
||||||
`apt-get update` 或安装 Debian Chromium。安装时不需要用户再执行浏览器下载命令。
|
只通过 Playwright 安装 Chromium 所需系统动态库,随后清理 apt 索引和临时缓存,不安装 Debian
|
||||||
|
仓库中的 Chromium。安装时不需要用户再执行浏览器下载命令。
|
||||||
|
|
||||||
| 平台 | 安装方式 | 服务标识 | 默认地址 |
|
| 平台 | 安装方式 | 服务标识 | 默认地址 |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ describe('frontend navigation routing', () => {
|
|||||||
test('logout button invalidates the backend session before clearing UI state', () => {
|
test('logout button invalidates the backend session before clearing UI state', () => {
|
||||||
const app = readFrontendFile('App.tsx');
|
const app = readFrontendFile('App.tsx');
|
||||||
|
|
||||||
expect(app).toContain('import { login, logout, verifySession }');
|
expect(app).toContain('import { initializeAdmin, login, logout, verifySession }');
|
||||||
expect(app).toContain('await logout();');
|
expect(app).toContain('await logout();');
|
||||||
expect(app).toContain('onLogout={handleLogout}');
|
expect(app).toContain('onLogout={handleLogout}');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user