1+ # 定义工作流名称
2+ name : build lvgl_micropython
3+
4+ # 触发条件:仅手动触发
5+ on :
6+ workflow_dispatch : # 仅手动触发
7+
8+ jobs :
9+ build_esp32 :
10+ # 指定运行环境为最新版的 Ubuntu
11+ runs-on : ubuntu-latest
12+ steps :
13+ # 第一步:检出代码
14+ - uses : actions/checkout@v4
15+ # 使用 GitHub 官方的 checkout 动作,版本为 v4,用于将代码仓库克隆到工作区
16+
17+ # 第二步:安装系统依赖
18+ - name : Install system dependencies
19+ run : |
20+ sudo apt-get update
21+ sudo apt-get install -y build-essential pkg-config cmake ninja-build ccache
22+ # 使用 apt-get 安装编译所需的系统级依赖工具,包括编译工具链、包配置工具、CMake 构建工具等
23+
24+ # 第三步:设置 Python 环境
25+ - uses : actions/setup-python@v5
26+ with :
27+ python-version : ' 3.11'
28+ # 使用 GitHub 官方的 setup-python 动作,版本为 v5,设置 Python 环境为 3.11
29+
30+ # 第四步:安装项目依赖
31+ - name : Install Deps
32+ run : |
33+ git submodule update --init --depth 1 -- lib/pycparser
34+ git submodule update --init --depth 1 --jobs 4 -- lib/micropython
35+ git submodule update --init --depth 1 --jobs 4 -- lib/lvgl
36+ # 初始化并更新 Git 子模块,深度为 1,用于获取项目依赖的子模块(如 pycparser、micropython 和 lvgl)
37+
38+ # 第五步:缓存依赖
39+ - name : Cached Deps
40+ id : cache-deps
41+ uses : actions/cache@v4
42+ with :
43+ path : |
44+ lib/esp-idf
45+ ~/.espressif
46+ key : ${{ runner.os }}-v4-deps
47+ # 使用 GitHub 官方的 cache 动作,版本为 v4,缓存 ESP-IDF 和 espressif 相关目录,以加速后续构建
48+
49+ # 第六步:获取构建依赖(如果缓存未命中)
50+ - name : Get Build Deps
51+ if : steps.cache-deps.outputs.cache-hit != 'true'
52+ run : |
53+ git submodule update --init --depth 1 --jobs 4 -- lib/esp-idf
54+ cd lib/esp-idf
55+ git submodule update --init --depth 1 --jobs 4 -- components/bt/host/nimble/nimble components/esp_wifi components/esptool_py/esptool components/lwip/lwip components/mbedtls/mbedtls components/bt/controller/lib_esp32 components/bt/controller/lib_esp32c3_family
56+ cd ../..
57+ export "IDF_PATH=${GITHUB_WORKSPACE}/lib/esp-idf"
58+ ./lib/esp-idf/install.sh all
59+ # 如果缓存未命中,则重新初始化 ESP-IDF 子模块,并安装 ESP-IDF 的所有依赖
60+
61+ # 第七步:设置 ESP-IDF 环境
62+ - name : Setup ESP-IDF
63+ run : |
64+ export "IDF_PATH=${GITHUB_WORKSPACE}/lib/esp-idf"
65+ . ./lib/esp-idf/export.sh
66+ env :
67+ IDF_PATH : ${{ github.workspace }}/lib/esp-idf
68+ # 设置 ESP-IDF 的环境变量,并加载其导出脚本,以便在后续步骤中使用 ESP-IDF
69+
70+ # 第八步:构建 ESP32 项目(矩阵策略)
71+ - name : Build ESP32
72+ run : |
73+ python3 make.py esp32 BOARD=${{ matrix.board }} BOARD_VARIANT=${{ matrix.variant }} --flash-size=${{ matrix.flash_size }} DISPLAY=${{ matrix.display }} INDEV=${{ matrix.indev }}
74+ # 使用 Python 脚本 make.py 构建 ESP32 项目,参数通过矩阵策略动态传入
75+ strategy :
76+ fail-fast : false # 如果一个矩阵任务失败,不会立即停止其他任务
77+ matrix :
78+ include :
79+ - board : ESP32_GENERIC_S3
80+ variant : SPIRAM_OCT
81+ flash_size : 16
82+ display : ili9341
83+ indev : gt911
84+ - board : ESP32_GENERIC_C3
85+ variant : " "
86+ flash_size : 8
87+ display : st7789
88+ indev : ft6x36
89+ - board : ESP32_GENERIC
90+ variant : SPIRAM
91+ flash_size : 4
92+ display : st7735
93+ indev : " "
94+ - board : ESP32_GENERIC
95+ variant : SPIRAM
96+ flash_size : 4
97+ display : ili9341
98+ indev : xpt2046
99+
100+ # 第九步:检查构建结果
101+ - name : Check build result
102+ id : check_build_result
103+ run : |
104+ if [ -f "${{ github.workspace }}/build/**/*.bin" ]; then
105+ echo "Build successful. .bin files found."
106+ echo "build_success=true" >> $GITHUB_ENV
107+ else
108+ echo "No .bin files found in build directory. Compilation failed. Skipping subsequent steps."
109+ echo "build_success=false" >> $GITHUB_ENV
110+ fi
111+ # 检查构建目录中是否存在 .bin 文件,如果没有找到,则设置环境变量 build_success 为 false
112+
113+ # 第十步:上传构建产物
114+ - name : Upload build artifact
115+ uses : actions/upload-artifact@v4
116+ if : ${{ env.build_success == 'true' }}
117+ with :
118+ name : lvgl_micropy_ESP32
119+ path : ${{ github.workspace }}/build/**/*.bin
120+ if-no-files-found : ignore
121+ # 仅当 build_success 为 true 时,上传构建生成的 .bin 文件
0 commit comments