完善 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:
Christ committed 2026-08-12 23:40:52 +08:00
1 parent 70e03a8523
commit d36c357bab
8 files changed
+280 -42

No files matched your search

+107 -5
View File
@@ -5,6 +5,8 @@ on:
branches:
- main
- codex/desktop-packaging
tags:
- 'v*.*.*'
workflow_dispatch:
permissions:
@@ -16,8 +18,53 @@ concurrency:
cancel-in-progress: true
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:
name: 构建镜像 (${{ matrix.arch }})
needs: verify
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
@@ -57,12 +104,17 @@ jobs:
go-version-file: go.mod
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
uses: actions/cache@v5
uses: actions/cache/restore@v5
with:
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
if: steps.cache-docker-playwright.outputs.cache-hit != 'true'
@@ -92,11 +144,18 @@ jobs:
chromium_path="$(find "$runtime_dir/playwright-browsers" -type f \
\( -name chrome -o -name headless_shell -o -name chrome-headless-shell \) -perm -111 -print -quit)"
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)')"
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)')"
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="$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_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
uses: docker/setup-buildx-action@v4
@@ -125,6 +184,48 @@ jobs:
provenance: mode=max
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: 保存镜像摘要
shell: bash
env:
@@ -175,6 +276,7 @@ jobs:
with:
images: ${{ steps.image.outputs.name }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=long