Skip to content

build many firmware

build many firmware #6

# 定义工作流名称
name: build many lvgl_micropython
# 触发条件:仅手动触发
on:
workflow_dispatch: # 仅手动触发
jobs:
build_esp32:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- board: ESP32_GENERIC_S3
variant: SPIRAM_OCT
flash_size: 16
display: ili9341
indev: gt911
- board: ESP32_GENERIC_C3
variant: ""
flash_size: 8
display: st7789
indev: ft6x36
- board: ESP32_GENERIC
variant: SPIRAM
flash_size: 4
display: st7735
indev: ""
- board: ESP32_GENERIC
variant: SPIRAM
flash_size: 4
display: ili9341
indev: xpt2046
steps:
# 1. 检出源码
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # 或者至少大于 1
# 2. 安装系统依赖
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config cmake ninja-build ccache
# 3. 设置 Python
- uses: actions/setup-python@v5
with:
python-version: '3.11'
# 4. 初始化子模块(项目依赖)
- name: Install Deps
run: |
git submodule update --init --depth 1 -- lib/pycparser
git submodule update --init --depth 1 --jobs 4 -- lib/micropython
git submodule update --init --depth 1 --jobs 4 -- lib/lvgl
# 5. 缓存 ESP-IDF
- name: Cached Deps
id: cache-deps
uses: actions/cache@v4
with:
path: |
lib/esp-idf
~/.espressif
key: ${{ runner.os }}-v4-deps
# 6. 若缓存未命中,拉取 ESP-IDF
- name: Get Build Deps
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
git submodule update --init --depth 1 --jobs 4 -- lib/esp-idf
cd lib/esp-idf
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
cd ../..
export "IDF_PATH=$GITHUB_WORKSPACE/lib/esp-idf"
./lib/esp-idf/install.sh all
# 7. 设置 ESP-IDF 环境
- name: Setup ESP-IDF
run: |
export "IDF_PATH=$GITHUB_WORKSPACE/lib/esp-idf"
. ./lib/esp-idf/export.sh
env:
IDF_PATH: ${{ github.workspace }}/lib/esp-idf
# 8. 构建固件
- name: Build ESP32
run: |
opts=()
[[ -n "${{ matrix.variant }}" ]] && opts+=("BOARD_VARIANT=${{ matrix.variant }}")
opts+=("BOARD=${{ matrix.board }}")
opts+=("--flash-size=${{ matrix.flash_size }}")
opts+=("DISPLAY=${{ matrix.display }}")
[[ -n "${{ matrix.indev }}" ]] && opts+=("INDEV=${{ matrix.indev }}")
python3 make.py esp32 "${opts[@]}"
# 9. 收集固件到统一目录
- name: Collect firmware
run: |
# 定义最终存放固件的目录,固定放到 $HOME/artifacts
ARTIFACTS_DIR="$HOME/artifacts"
mkdir -p "$ARTIFACTS_DIR" # 如果目录不存在则自动创建
# 拼出 ESP-IDF 实际编译输出目录的前缀
BUILD_DIR="${{ github.workspace }}/lib/micropython/ports/esp32"
# 拼出构建目录名:board 与可选 variant 用 “-” 连接
BOARD_NAME="${{ matrix.board }}"
[[ -n "${{ matrix.variant }}" ]] && BOARD_NAME+="-${{ matrix.variant }}"
# 计算固件真正所在路径
FW_PATH="${BUILD_DIR}/build-${BOARD_NAME}/firmware.bin"
OUT_NAME="lvgl_mpy_${{ matrix.board }}
${{ matrix.variant && format('_{0}', matrix.variant) || '' }}\

Check failure on line 123 in .github/workflows/build lvgl_mpy2.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build lvgl_mpy2.yml

Invalid workflow file

You have an error in your yaml syntax on line 123
_${{ matrix.flash_size }}MB\
${{ matrix.display && format('_{0}', matrix.display) || '' }}\
${{ matrix.indev && format('_{0}', matrix.indev) || '' }}.bin"
# 如果固件存在则复制并重命名;不存在则报错退出
if [[ -f "$FW_PATH" ]]; then
cp "$FW_PATH" "$ARTIFACTS_DIR/$OUT_NAME"
else
echo "Firmware not found at $FW_PATH"
exit 1
fi
# 10. 上传构建产物
- uses: actions/upload-artifact@v4
with:
name: lvgl_mpy_${{ matrix.board }}
${{ matrix.variant && format('_{0}', matrix.variant) || '' }}\
_${{ matrix.flash_size }}MB\
${{ matrix.display && format('_{0}', matrix.display) || '' }}\
${{ matrix.indev && format('_{0}', matrix.indev) || '' }}
path: ~/artifacts/*.bin