ci: 重构流水线配置,适配当前 Docker Runner 环境
This commit is contained in:
+26
-63
@@ -1,70 +1,47 @@
|
||||
# 美家卡智影 - GitLab CI/CD 配置
|
||||
# =======================================
|
||||
# 覆盖范围: 前端多平台构建 (macOS Universal + Windows x64)
|
||||
#
|
||||
# Runner 环境要求:
|
||||
# - macOS runner (标签: macos, arm64):
|
||||
# Apple Silicon Mac, 已安装:
|
||||
# - Xcode Command Line Tools (15+)
|
||||
# - Node.js 22+ (建议通过 nvm 管理)
|
||||
# - Rust 1.94+ (通过 rustup)
|
||||
# - GitLab Runner (shell executor)
|
||||
# - Windows runner (标签: windows, x86_64):
|
||||
# Windows 10/11 x64, 已安装:
|
||||
# - Visual Studio 2022 Build Tools (含 C++ 桌面开发工具链)
|
||||
# - Node.js 22+ (建议通过 nvm-windows 管理)
|
||||
# - Rust 1.94+ (通过 rustup)
|
||||
# - GitLab Runner (shell executor)
|
||||
#
|
||||
# 触发条件: master 分支推送 或 tag 推送
|
||||
# 产物保留: 30 天
|
||||
# 当前可用 Runner: docker/build (Linux Docker)
|
||||
# macOS/Windows 构建需手动触发,且需要对应 Runner
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG
|
||||
|
||||
variables:
|
||||
ARTIFACT_EXPIRE_DAYS: "30"
|
||||
|
||||
stages:
|
||||
- check
|
||||
- build-frontend
|
||||
|
||||
# ==========================================
|
||||
# 通用模板: 前端构建
|
||||
# Stage 1: 基础检查(在 Docker Runner 上自动执行)
|
||||
# ==========================================
|
||||
.frontend_build:
|
||||
stage: build-frontend
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG
|
||||
when: manual
|
||||
cache:
|
||||
# Node 依赖缓存(基于 package-lock.json 变更)
|
||||
- key:
|
||||
files:
|
||||
- tauri-app/package-lock.json
|
||||
paths:
|
||||
- tauri-app/node_modules/
|
||||
# Rust 编译缓存(基于 Cargo.lock 变更)
|
||||
- key:
|
||||
files:
|
||||
- tauri-app/src-tauri/Cargo.lock
|
||||
paths:
|
||||
- tauri-app/src-tauri/target/
|
||||
validate-config:
|
||||
stage: check
|
||||
tags:
|
||||
- docker
|
||||
script:
|
||||
- echo "验证项目配置..."
|
||||
- test -f tauri-app/src-tauri/tauri.conf.json
|
||||
- test -f tauri-app/package.json
|
||||
- test -f tauri-app/src-tauri/Cargo.toml
|
||||
- echo "所有配置文件存在,验证通过"
|
||||
|
||||
# ==========================================
|
||||
# Job: macOS Universal 构建 (ARM64 + Intel)
|
||||
# Stage 2: 前端构建(手动触发,需要特定 Runner)
|
||||
# ==========================================
|
||||
# 说明:
|
||||
# - 在 Apple Silicon Mac 上同时编译 ARM64 和 x86_64 两个架构
|
||||
# - 使用 lipo 合并为 universal Mach-O 可执行文件
|
||||
# - 产物为单一 .dmg,同时支持 M 系列和 Intel Mac
|
||||
|
||||
# macOS Universal 构建
|
||||
build-frontend-macos:
|
||||
extends: .frontend_build
|
||||
stage: build-frontend
|
||||
tags:
|
||||
- macos
|
||||
- arm64
|
||||
when: manual
|
||||
before_script:
|
||||
# 激活 Rust 环境 (rustup 默认安装路径)
|
||||
- source "$HOME/.cargo/env" 2>/dev/null || true
|
||||
# 安装 Intel 目标平台(构建 universal binary 必需)
|
||||
- rustup target add x86_64-apple-darwin
|
||||
# 验证构建环境
|
||||
- node --version
|
||||
- npm --version
|
||||
- cargo --version
|
||||
@@ -72,15 +49,11 @@ build-frontend-macos:
|
||||
script:
|
||||
- cd tauri-app
|
||||
- npm ci
|
||||
# 构建 universal macOS 应用
|
||||
# Tauri 会自动分别编译 aarch64 和 x86_64,再合并为 universal binary
|
||||
- npm run tauri -- build --target universal-apple-darwin
|
||||
artifacts:
|
||||
name: "meijiaka-macos-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
# DMG 安装包 (推荐用户下载)
|
||||
- tauri-app/src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
||||
# Updater 专用包 + 签名
|
||||
- tauri-app/src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app.tar.gz
|
||||
- tauri-app/src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app.tar.gz.sig
|
||||
expire_in: "${ARTIFACT_EXPIRE_DAYS} days"
|
||||
@@ -89,20 +62,14 @@ build-frontend-macos:
|
||||
max: 1
|
||||
when: runner_system_failure
|
||||
|
||||
# ==========================================
|
||||
# Job: Windows x64 构建
|
||||
# ==========================================
|
||||
# 说明:
|
||||
# - 产物包含 NSIS (.exe) 和 MSI 两种安装包格式
|
||||
# - NSIS 已配置为简体中文安装界面
|
||||
# - sidecar (ffmpeg/ffprobe) 会自动嵌入 .exe 同目录
|
||||
# Windows x64 构建
|
||||
build-frontend-windows:
|
||||
extends: .frontend_build
|
||||
stage: build-frontend
|
||||
tags:
|
||||
- windows
|
||||
- x86_64
|
||||
when: manual
|
||||
before_script:
|
||||
# 验证构建环境
|
||||
- rustc --version
|
||||
- cargo --version
|
||||
- node --version
|
||||
@@ -110,17 +77,13 @@ build-frontend-windows:
|
||||
script:
|
||||
- cd tauri-app
|
||||
- npm ci
|
||||
# 构建 Windows x64 应用
|
||||
- npm run tauri -- build --target x86_64-pc-windows-msvc
|
||||
artifacts:
|
||||
name: "meijiaka-windows-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
# Updater 专用包 + 签名
|
||||
- tauri-app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe
|
||||
- tauri-app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe.sig
|
||||
# NSIS 安装包 (推荐用户下载)
|
||||
- tauri-app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*-setup.exe
|
||||
# MSI 安装包 (企业部署场景)
|
||||
- tauri-app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi
|
||||
expire_in: "${ARTIFACT_EXPIRE_DAYS} days"
|
||||
timeout: 45 minutes
|
||||
|
||||
Reference in New Issue
Block a user