统一服务默认端口为 59188,完善 Windows 服务权限与 macOS LaunchAgent 管理。 实现 Windows 与 macOS 托盘状态机、服务启停等待、单实例保护、日志目录入口和退出前清理后台服务。 统一 Linux、Windows、macOS 与 Docker 的 Playwright Chromium runtime 构建流程,增加缓存、架构校验和 Linux 原生 runner,避免 QEMU。 完善 Windows、macOS、Linux 安装包及签名打包脚本,修正 Chromium 嵌入、服务注册和安装卸载流程。 同步 README、AGENTS、官网首页、Wiki 与前端开发文档,统一端口、初始化、服务、日志、托盘和安装说明。
168 lines
5.1 KiB
YAML
168 lines
5.1 KiB
YAML
name: 构建并发布 Docker 镜像
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- codex/desktop-packaging
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
concurrency:
|
|
group: docker-publish-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
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: 校验 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
|
|
|
|
- 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: 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
|
|
with:
|
|
images: ${{ steps.image.outputs.name }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,format=long
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
type=raw,value=alpha,enable=${{ github.ref == 'refs/heads/codex/desktop-packaging' }}
|
|
|
|
- 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"
|