Skip to content

Commit cf8089a

Browse files
committed
Refactor CI/CD workflow: multi-platform, multi-NDK, multi-config builds
- Rename workflow file from android.yml to build.yml (best practice) - Support 3 OS platforms: Windows, macOS, Ubuntu - Support 2 NDK versions: r26d (stable), r27c (latest) - Support 2 build systems: CMake and ndk-build - Support 4 product variants: ±FFmpeg × ±16KB page size - Total 48 build configurations (3×2×2×2×2) Trigger strategy: - Master branch: Full build (48 jobs) - Pull requests: Simplified build (18 jobs) - Windows: 1 job (r26d, CMake, FFmpeg, 16KB) - macOS: 1 job (r27c, ndk-build, no-FFmpeg, 4KB) - Ubuntu: 16 jobs (full matrix) - Other branches: No build (save resources) Features: - Structured artifact naming: apk-{OS}-{NDK}-{BuildSystem}-{FFmpeg}-{PageSize} - Conditional job execution based on branch - Cross-platform build tool installation - Separate lint job for code quality (master only) - Added comprehensive workflow documentation
1 parent 35792b5 commit cf8089a

3 files changed

Lines changed: 632 additions & 51 deletions

File tree

.github/workflows/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# CI/CD Workflow 说明
2+
3+
## 概述
4+
5+
本项目使用 GitHub Actions 进行持续集成和构建。Workflow 配置文件:[build.yml](./build.yml)
6+
7+
## 构建矩阵
8+
9+
### 维度说明
10+
11+
项目支持以下构建配置的组合:
12+
13+
1. **操作系统** (3种)
14+
- Windows (windows-latest)
15+
- macOS (macos-latest)
16+
- Ubuntu (ubuntu-latest)
17+
18+
2. **NDK 版本** (2种)
19+
- r26d (稳定版本)
20+
- r27c (较新版本)
21+
22+
3. **构建系统** (2种)
23+
- CMake (`--enable-cmake`)
24+
- ndk-build (传统构建方式)
25+
26+
4. **FFmpeg 支持** (2种)
27+
- with-ffmpeg (`--enable-video-module`) - 支持视频录制功能
28+
- no-ffmpeg (`--disable-video-module`) - 纯图片处理,体积更小
29+
30+
5. **内存页大小** (2种)
31+
- 4kb (默认) (`--disable-16kb-page-size`)
32+
- 16kb (`--enable-16kb-page-size`) - 针对新 Android 设备优化
33+
34+
理论上共有 **3 × 2 × 2 × 2 × 2 = 48** 种组合。
35+
36+
## 触发策略
37+
38+
### 1. Master 分支推送 (全量构建)
39+
40+
当代码推送到 `master` 分支时,运行**所有 48 个构建任务**,确保所有配置组合都能正常工作。
41+
42+
```yaml
43+
on:
44+
push:
45+
branches: [ "master" ]
46+
```
47+
48+
**构建任务数量:** 48
49+
- Windows: 16 (2 NDK × 2 build-system × 2 ffmpeg × 2 page-size)
50+
- macOS: 16 (2 NDK × 2 build-system × 2 ffmpeg × 2 page-size)
51+
- Ubuntu: 16 (2 NDK × 2 build-system × 2 ffmpeg × 2 page-size)
52+
53+
### 2. Pull Request (精简构建)
54+
55+
PR 时运行**精简的 18 个构建任务**,在保证质量的同时节省资源:
56+
57+
```yaml
58+
on:
59+
pull_request:
60+
branches: [ "master" ]
61+
```
62+
63+
**构建任务数量:** 18
64+
65+
#### Windows (1个任务)
66+
- NDK: r26d
67+
- 构建系统: CMake
68+
- FFmpeg: 启用
69+
- 页大小: 16KB
70+
71+
#### macOS (1个任务)
72+
- NDK: r27c
73+
- 构建系统: ndk-build
74+
- FFmpeg: 禁用
75+
- 页大小: 4KB
76+
77+
#### Ubuntu (16个任务 - 全量)
78+
- NDK: r26d + r27c
79+
- 构建系统: CMake + ndk-build
80+
- FFmpeg: 启用 + 禁用
81+
- 页大小: 4KB + 16KB
82+
- 全部组合: 2 × 2 × 2 × 2 = 16
83+
84+
### 3. 其他分支推送
85+
86+
非 master 分支的推送**不会触发** workflow,避免资源浪费。只有创建 PR 时才会触发精简构建。
87+
88+
## 产物命名规则
89+
90+
构建产物 (APK) 使用以下命名格式:
91+
92+
```
93+
apk-{OS}-{NDK}-{BuildSystem}-{FFmpeg}-{PageSize}.apk
94+
```
95+
96+
**示例:**
97+
- `apk-Linux-r26d-cmake-ffmpeg-4kb.apk`
98+
- `apk-Windows-r27c-ndk-build-noffmpeg-16kb.apk`
99+
- `apk-macOS-r26d-cmake-ffmpeg-16kb.apk`
100+
101+
## Lint 检查
102+
103+
代码质量检查仅在 master 分支推送时运行,确保主干代码质量。
104+
105+
## 本地测试
106+
107+
可以使用项目根目录的 `tasks.sh` 脚本在本地进行构建测试:
108+
109+
```bash
110+
# CMake 构建,启用视频模块,16KB 页大小
111+
./tasks.sh --release --enable-cmake --enable-video-module --enable-16kb-page-size --build
112+
113+
# ndk-build 构建,禁用视频模块,默认页大小
114+
./tasks.sh --release --disable-video-module --disable-16kb-page-size --build
115+
```
116+
117+
## 注意事项
118+
119+
1. **NDK 版本**:确保本地安装了对应版本的 NDK
120+
2. **构建时间**:全量构建(48个任务)可能需要较长时间
121+
3. **产物大小**:启用 FFmpeg 的版本体积较大(包含视频编解码库)
122+
4. **页大小**:16KB 页大小版本需要 Android API 35+ 支持
123+
124+
## 资源优化
125+
126+
通过 PR 精简构建策略(18个任务 vs 48个任务),可以:
127+
- 节省约 62.5% 的 CI/CD 资源
128+
- 缩短 PR 反馈时间
129+
- 保持足够的测试覆盖率(Ubuntu 全量测试)

.github/workflows/android.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)