new #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ESP32 | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - '**' | |
| paths: | |
| - 'src/**' | |
| - '.github/workflows/*.yml' | |
| - 'boards/**' | |
| tags-ignore: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - master | |
| paths: | |
| - 'src/**' | |
| - '.github/workflows/*.yml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| MICROPYTHON_DIR: ~/micropython | |
| ESP_IDF_DIR: ~/esp-idf | |
| ARTIFACTS_DIR: ~/artifacts | |
| jobs: | |
| setup-environment: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - 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 | |
| - name: Cache ESP-IDF and MicroPython | |
| id: cache_esp_idf | |
| uses: actions/cache@v4 | |
| with: | |
| lookup-only: true | |
| path: | | |
| ${{ env.ESP_IDF_DIR }} | |
| ~/.espressif/ | |
| ~/.cache/pip/ | |
| ${{ env.MICROPYTHON_DIR }} | |
| key: mpy-${{ env.MPY_RELEASE }} | |
| restore-keys: mpy- | |
| - name: Install dependencies (if not cached) | |
| 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 | |
| - name: Clone MicroPython latest release (if not cached) | |
| if: steps.cache_esp_idf.outputs.cache-hit != 'true' | |
| run: | | |
| cd ~ | |
| # git clone --depth 1 --branch mp-dl https://github.com/cnadler86/micropython.git ${{ env.MICROPYTHON_DIR }} | |
| git clone https://github.com/micropython/micropython.git ${{ env.MICROPYTHON_DIR }} | |
| cd ${{ env.MICROPYTHON_DIR }} | |
| git submodule update --init --depth 1 | |
| cd mpy-cross && make | |
| - name: Set up ESP-IDF | |
| if: steps.cache_esp_idf.outputs.cache-hit != 'true' | |
| run: | | |
| cd ~ | |
| # git clone --depth 1 --branch release/v5.4 https://github.com/espressif/esp-idf.git ${{ env.ESP_IDF_DIR }} | |
| git clone --depth 1 --branch v5.4.2 https://github.com/espressif/esp-idf.git ${{ env.ESP_IDF_DIR }} | |
| git -C ${{ env.ESP_IDF_DIR }} submodule update --init --recursive --filter=tree:0 | |
| cd ${{ env.ESP_IDF_DIR }} && ./install.sh esp32s3 | |
| source ./export.sh | |
| build: | |
| needs: setup-environment | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| board: | |
| - ESP32_GENERIC_S3-SPIRAM_OCT | |
| - ESP32_GENERIC_S3-FLASH_4M | |
| - ESP32_GENERIC_S3-FLASH_16M | |
| - ESP32_GENERIC_S3-FLASH_16M@FREENOVE_ESP32S3_CAM | |
| - ESP32_GENERIC_S3-FLASH_16M@DFRobot_ESP32S3 | |
| - ESP32_GENERIC_S3-SPIRAM_OCT@XIAO_ESP32S3 | |
| - ESP32_GENERIC_S3-SPIRAM_OCT@DFRobot_ESP32S3_AI | |
| steps: | |
| - 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 | |
| - name: Cache ESP-IDF and MicroPython | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ env.ESP_IDF_DIR }} | |
| ~/.espressif/ | |
| ~/.cache/pip/ | |
| ${{ env.MICROPYTHON_DIR }} | |
| key: mpy-${{ env.MPY_RELEASE }} | |
| restore-keys: mpy- | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Build MicroPython | |
| run: | | |
| source ${{ env.ESP_IDF_DIR }}/export.sh | |
| cd ${{ github.workspace }} && cd .. | |
| git clone https://github.com/Vincent1-python/micropython-camera-API.git | |
| git clone https://github.com/cnadler86/mp_jpeg.git | |
| cd ${{ github.workspace }}/boards/ | |
| # 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}" | |
| IDF_CMD="idf.py -D MICROPY_DIR=${{ env.MICROPYTHON_DIR }} -D MICROPY_BOARD=$BOARD_NAME -B build-$BUILD_TARGET" | |
| 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 | |
| FINAL_CMD="${IDF_CMD} -D MICROPY_CAMERA_MODEL=${CAMERA_MODEL} build" | |
| else | |
| echo "FW_NAME=${BUILD_TARGET}" >> $GITHUB_ENV | |
| FINAL_CMD="${IDF_CMD} build" | |
| fi | |
| eval "$FINAL_CMD" | |
| cd build-$BUILD_TARGET | |
| python ${{ env.MICROPYTHON_DIR }}/ports/esp32/makeimg.py sdkconfig bootloader/bootloader.bin partition_table/partition-table.bin micropython.bin firmware.bin micropython.uf2 | |
| mkdir -p ${{ env.ARTIFACTS_DIR }} | |
| mv firmware.bin ${{ env.ARTIFACTS_DIR }}/firmware-$BUILD_TARGET.bin | |
| - name: Upload firmware artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: firmware-${{ env.MPY_RELEASE }}-${{ env.FW_NAME }} | |
| path: ${{ env.ARTIFACTS_DIR }}/** | |
| retention-days: 5 | |
| - name: Upload build logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-logs-${{ matrix.board }} | |
| path: | | |
| ${{ github.workspace }}/boards/build-${{ matrix.board }}/log/ | |
| retention-days: 5 |