Skip to content

update pipeline

update pipeline #290

Workflow file for this run

name: ESP32
on:
workflow_dispatch:
push:
branches:
- '**'
paths:
- 'src/**'
- '.github/workflows/*.yml'
tags-ignore:
- 'v*'
pull_request:
branches:
- master
paths:
- 'src/**'
- '.github/workflows/*.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup-environment:
runs-on: ubuntu-24.04
steps:
# Get the latest MicroPython release
- name: Get MicroPython latest release
run: |
MPY_RELEASE=$(curl --silent "https://api.github.com/repos/micropython/micropython/releases/latest" | jq -r .tag_name)
echo "MPY_RELEASE=${MPY_RELEASE}" >> $GITHUB_ENV
# Cache ESP-IDF dependencies and MicroPython
- name: Cache ESP-IDF and MicroPython
id: cache_esp_idf
uses: actions/cache@v4
with:
lookup-only: true
path: |
~/esp-idf/
~/.espressif/
!~/.espressif/dist/
~/.cache/pip/
~/micropython/
key: mpy-${{ env.MPY_RELEASE }}
restore-keys: mpy-
# Install ESP-IDF dependencies (if not cached)
- name: Install dependencies
if: steps.cache_esp_idf.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
# Clone MicroPython (if not cached)
- name: Clone MicroPython
id: clone-micropython
if: steps.cache_esp_idf.outputs.cache-hit != 'true'
run: |
cd ~
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
echo "Master branch detected - cloning MicroPython release: $MPY_RELEASE"
git clone --depth 1 --branch ${{ env.MPY_RELEASE }} https://github.com/micropython/micropython.git
else
echo "Development branch detected - cloning latest MicroPython master"
git clone --depth 1 https://github.com/micropython/micropython.git
fi
cd micropython
cd mpy-cross
make
echo "Micropython setup successfully"
source ~/micropython/tools/ci.sh && echo "IDF_VER=$IDF_VER" >> $GITHUB_ENV
# Download and set up ESP-IDF (if not cached)
- name: Set up ESP-IDF
id: export-idf
if: steps.cache_esp_idf.outputs.cache-hit != 'true'
run: |
cd ~
# git clone --depth 1 --branch v5.5.1 https://github.com/espressif/esp-idf.git
git clone --depth 1 --branch ${{ env.IDF_VER }} https://github.com/espressif/esp-idf.git
git -C esp-idf submodule update --init --recursive --filter=tree:0
cd esp-idf
./install.sh all
source ./export.sh
# Dynamically create jobs for each board
build:
needs: setup-environment
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
board:
- ESP32_GENERIC-SPIRAM
- ESP32_GENERIC_S2
- ESP32_GENERIC_S3
- ESP32_GENERIC_S3-SPIRAM_OCT
- ESP32_GENERIC-SPIRAM@WROVER_KIT
- ESP32_GENERIC-SPIRAM@ESP_EYE
- ESP32_GENERIC-SPIRAM@M5STACK_PSRAM
- ESP32_GENERIC-SPIRAM@M5STACK_V2_PSRAM
- ESP32_GENERIC-SPIRAM@M5STACK_WIDE
- ESP32_GENERIC-SPIRAM@M5STACK_ESP32CAM
- ESP32_GENERIC-SPIRAM@M5STACK_UNITCAM
- ESP32_GENERIC-SPIRAM@AI_THINKER
- ESP32_GENERIC-SPIRAM@TTGO_T_JOURNAL
- ESP32_GENERIC-SPIRAM@TTGO_T_CAMERA_PLUS
- ESP32_GENERIC_S3-SPIRAM_OCT@M5STACK_CAMS3_UNIT
- ESP32_GENERIC_S3-SPIRAM_OCT@M5STACK_ATOM_S3R
- ESP32_GENERIC_S3-SPIRAM_OCT@XIAO_ESP32S3
- ESP32_GENERIC_S3-SPIRAM_OCT@ESP32S3_CAM_LCD
- ESP32_GENERIC_S3-SPIRAM_OCT@ESP32S3_EYE
- ESP32_GENERIC_S3-SPIRAM_OCT@FREENOVE_ESP32S3_CAM
- ESP32_GENERIC_S3-SPIRAM_OCT@DFRobot_ESP32S3
- ESP32_GENERIC_S3-SPIRAM_OCT@NEW_ESPS3_RE1_0
- ESP32_GENERIC_S3-SPIRAM_OCT@XENOIONEX
steps:
# Get the latest MicroPython release
- name: Get MicroPython latest release
run: |
MPY_RELEASE=$(curl --silent "https://api.github.com/repos/micropython/micropython/releases/latest" | jq -r .tag_name)
echo "MPY_RELEASE=${MPY_RELEASE}" >> $GITHUB_ENV
# Cache ESP-IDF dependencies and MicroPython
- name: Cache ESP-IDF and MicroPython
uses: actions/cache@v4
with:
path: |
~/esp-idf/
~/.espressif/
!~/.espressif/dist/
~/.cache/pip/
~/micropython/
key: mpy-${{ env.MPY_RELEASE }}
restore-keys: mpy-
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install ESP-IDF dependencies
run: |
sudo apt-get update
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 build-essential pkg-config
# Build MicroPython for each board
- name: Build MicroPython
run: |
cd ${{ github.workspace }}
cd ..
git clone https://github.com/cnadler86/mp_jpeg.git
# cd ~/esp32-camera
# CAM_DRIVER=$(git describe --tags --always --dirty)
cd ~/micropython/ports/esp32
source ~/esp-idf/export.sh
# Check if a variant is defined and adjust the idf.py command
IFS='@' read -r BUILD_TARGET CAMERA_MODEL <<< "${{ matrix.board }}"
IFS='-' read -r BOARD_NAME BOARD_VARIANT <<< "${BUILD_TARGET}"
# Build command step by step
IDF_CMD="idf.py -D MICROPY_BOARD=$BOARD_NAME -D USER_C_MODULES=${{ github.workspace }}/micropython.cmake -B build-$BUILD_TARGET -D EXTRA_COMPONENT_DIRS=${{ github.workspace }}"
if [ -n "${BOARD_VARIANT}" ]; then
IDF_CMD="${IDF_CMD} -D MICROPY_BOARD_VARIANT=$BOARD_VARIANT"
fi
if [ -n "${CAMERA_MODEL}" ]; then
echo "FW_NAME=${CAMERA_MODEL}" >> $GITHUB_ENV
IDF_CMD="${IDF_CMD} -D MICROPY_CAMERA_MODEL=${CAMERA_MODEL}"
else
echo "FW_NAME=${BUILD_TARGET}" >> $GITHUB_ENV
fi
FINAL_CMD="${IDF_CMD} build"
make BOARD=$BOARD_NAME submodules
echo "Running command: $FINAL_CMD"
eval $FINAL_CMD
cd ~/micropython/ports/esp32/build-${BUILD_TARGET}
python ../makeimg.py sdkconfig bootloader/bootloader.bin partition_table/partition-table.bin micropython.bin firmware.bin micropython.uf2
mkdir -p ~/artifacts
mv ~/micropython/ports/esp32/build-${BUILD_TARGET}/firmware.bin ~/artifacts/firmware.bin
- name: Upload firmware artifact
uses: actions/upload-artifact@v4
with:
name: mpy_cam-${{ env.MPY_RELEASE }}-${{ env.FW_NAME }}
path: ~/artifacts/**
retention-days: 5