Compile All #29
This file contains 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: Compile Generics | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build for ${{ matrix.target.name }} - LED ${{ matrix.target.led }} - Screen ${{ matrix.target.screen_support }} - Input ${{ matrix.target.input_type }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
# Generic configurations (no LED, no screen support) | |
- { name: "esp32-generic", idf_target: "esp32", led: false, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32-generic.zip" } | |
- { name: "esp32s2-generic", idf_target: "esp32s2", led: false, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32s2-generic.zip" } | |
- { name: "esp32s3-generic", idf_target: "esp32s3", led: false, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32s3-generic.zip" } | |
- { name: "esp32c3-generic", idf_target: "esp32c3", led: false, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32c3-generic.zip" } | |
- { name: "esp32c6-generic", idf_target: "esp32c6", led: false, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32c6-generic.zip" } | |
# Dev Kit configurations (LED on, no screen support) | |
- { name: "esp32c3-devkit", idf_target: "esp32c3", led: true, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32c3-devkit.zip", led_pin: 8, num_leds: 1 } | |
- { name: "esp32c6-devkit", idf_target: "esp32c6", led: true, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "esp32c6-devkit.zip", led_pin: 8, num_leds: 1 } | |
# Ghost board (LED on, special pin and LED count) | |
- { name: "ghostboard", idf_target: "esp32c6", led: true, screen_support: false, input_type: "none", sdkconfig_file: "configs/sdkconfig.default", zip_name: "ghostboard.zip", led_pin: 10, num_leds: 3, is_ghost_board: true } | |
# Screen-supported builds | |
- { name: "MarauderV6&AwokDual", idf_target: "esp32", led: false, screen_support: true, input_type: "touchscreen", sdkconfig_file: "configs/sdkconfig.marauderv6", zip_name: "MarauderV6_AwokDual.zip", screen_width: 240, screen_height: 320 } | |
- { name: "AwokMini", idf_target: "esp32", led: false, screen_support: true, input_type: "joystick", sdkconfig_file: "configs/sdkconfig.awokmini", zip_name: "AwokMini.zip", screen_width: 128, screen_height: 128 } | |
- { name: "ESP32-S3-Cardputer", idf_target: "esp32s3", led: false, screen_support: true, input_type: "cardputer", sdkconfig_file: "configs/sdkconfig.default", zip_name: "ESP32-S3-Cardputer.zip", screen_width: 240, screen_height: 135 } | |
# CYD (Cheap Yellow Display) with touch screen | |
#- { name: "CYD-1", idf_target: "esp32", led: false, screen_support: true, input_type: "touchscreen", sdkconfig_file: "configs/sdkconfig_cyd_1", zip_name: "CYD-1.zip", screen_width: 240, screen_height: 320 } | |
#- { name: "CYD-2", idf_target: "esp32", led: false, screen_support: true, input_type: "touchscreen", sdkconfig_file: "configs/sdkconfig_cyd_2", zip_name: "CYD-2.zip", screen_width: 240, screen_height: 320 } | |
# 7-inch boards | |
- { name: "Waveshare_LCD", idf_target: "esp32s3", led: false, screen_support: true, input_type: "touchscreen", sdkconfig_file: "configs/sdkconfig.waveshare7inch", zip_name: "Waveshare_LCD.zip", screen_width: 800, screen_height: 480, use_7_incher: true, waveshare_lcd: true } | |
- { name: "Crowtech_LCD", idf_target: "esp32s3", led: false, screen_support: true, input_type: "touchscreen", sdkconfig_file: "configs/sdkconfig.crowtech7inch", zip_name: "Crowtech_LCD.zip", screen_width: 800, screen_height: 480, use_7_incher: true, crowtech_lcd: true } | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Cache ESP-IDF and Tools | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.espressif | |
~/.idf_tools | |
~/.cache/pip | |
key: ${{ runner.os }}-esp-idf-${{ matrix.target.name }}-${{ matrix.led }}-${{ matrix.screen_support }}-${{ matrix.input_type }} | |
restore-keys: | | |
${{ runner.os }}-esp-idf-${{ matrix.target.name }}- | |
${{ runner.os }}-esp-idf- | |
# Manual ESP-IDF Installation | |
- name: Install ESP-IDF | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y wget git flex bison gperf python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util | |
git clone -b v5.3.1 --depth 1 https://github.com/espressif/esp-idf.git ~/esp-idf | |
~/esp-idf/install.sh | |
- name: Apply Custom SDK Config | |
run: | | |
DEST_FILE="sdkconfig" | |
echo "Applying SDK Config: ${{matrix.target.sdkconfig_file}} to $DEST_FILE" | |
if [ -f "${{matrix.target.sdkconfig_file}}" ]; then | |
cp "${{matrix.target.sdkconfig_file}}" "$DEST_FILE" | |
else | |
echo "Error: Source config file ${{matrix.target.sdkconfig_file}} does not exist." | |
exit 1 | |
fi | |
- name: Set ESP-IDF Target in SDK Config | |
run: | | |
TARGET_VAR="CONFIG_IDF_TARGET=${{ matrix.target.idf_target }}" | |
SDKCONFIG_FILE="${{ matrix.target.sdkconfig_file }}" | |
echo "Setting target in SDK Config: $TARGET_VAR in $SDKCONFIG_FILE" | |
if grep -q "^CONFIG_IDF_TARGET=" "$SDKCONFIG_FILE"; then | |
sed -i "s/^CONFIG_IDF_TARGET=.*/$TARGET_VAR/" "$SDKCONFIG_FILE" | |
else | |
echo "$TARGET_VAR" >> "$SDKCONFIG_FILE" | |
fi | |
- name: Set Environment Variables for Matrix Configuration | |
run: | | |
if [ "${{ matrix.target.led }}" = "true" ]; then | |
echo "LED_DATA_PIN=${{ matrix.target.led_pin }}" >> $GITHUB_ENV | |
echo "NUM_LEDS=${{ matrix.target.num_leds }}" >> $GITHUB_ENV | |
fi | |
if [ "${{ matrix.target.is_ghost_board }}" = "true" ]; then | |
echo "IS_GHOST_BOARD=1" >> $GITHUB_ENV | |
fi | |
if [ "${{ matrix.target.screen_support }}" = "true" ]; then | |
echo "WITH_SCREEN=1" >> $GITHUB_ENV | |
echo "TFT_WIDTH=${{ matrix.target.screen_width }}" >> $GITHUB_ENV | |
echo "TFT_HEIGHT=${{ matrix.target.screen_height }}" >> $GITHUB_ENV | |
fi | |
case "${{ matrix.target.input_type }}" in | |
"touchscreen") | |
echo "USE_TOUCHSCREEN=1" >> $GITHUB_ENV | |
;; | |
"joystick") | |
echo "USE_JOYSTICK=1" >> $GITHUB_ENV | |
;; | |
"cardputer") | |
echo "USE_CARDPUTER=1" >> $GITHUB_ENV | |
;; | |
esac | |
if [ "${{ matrix.target.use_7_incher }}" = "true" ]; then | |
echo "USE_7_INCHER=0" >> $GITHUB_ENV | |
fi | |
if [ "${{ matrix.target.waveshare_lcd }}" = "true" ]; then | |
echo "Waveshare_LCD=1" >> $GITHUB_ENV | |
fi | |
if [ "${{ matrix.target.crowtech_lcd }}" = "true" ]; then | |
echo "Crowtech_LCD=1" >> $GITHUB_ENV | |
fi | |
- name: Clean Build Environment | |
run: | | |
. ~/esp-idf/export.sh | |
idf.py fullclean | |
- name: Build Project | |
run: | | |
. ~/esp-idf/export.sh | |
idf.py build | |
- name: Package Build Artifacts | |
run: | | |
. ~/esp-idf/export.sh | |
mkdir -p packaged_artifacts | |
BOOTLOADER_BIN=build/bootloader/bootloader.bin | |
PARTITION_TABLE_BIN=build/partition_table/partition-table.bin | |
GHOST_ESP_IDF_BIN=build/Ghost_ESP_IDF.bin | |
if [ ! -f "$BOOTLOADER_BIN" ]; then | |
echo "Error: $BOOTLOADER_BIN not found!" | |
exit 1 | |
fi | |
if [ ! -f "$PARTITION_TABLE_BIN" ]; then | |
echo "Error: $PARTITION_TABLE_BIN not found!" | |
exit 1 | |
fi | |
if [ ! -f "$GHOST_ESP_IDF_BIN" ]; then | |
echo "Error: $GHOST_ESP_IDF_BIN not found!" | |
exit 1 | |
fi | |
cp "$BOOTLOADER_BIN" packaged_artifacts/ | |
cp "$PARTITION_TABLE_BIN" packaged_artifacts/ | |
cp "$GHOST_ESP_IDF_BIN" packaged_artifacts/ | |
ZIP_NAME="${{ matrix.target.zip_name }}" | |
cd packaged_artifacts | |
zip "$ZIP_NAME" bootloader.bin partition-table.bin Ghost_ESP_IDF.bin | |
cd .. | |
- name: Get the Latest Release ID | |
id: get_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
latest_release=$(curl -s \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/latest") | |
release_id=$(echo "$latest_release" | jq -r '.id') | |
echo "Latest release ID is $release_id" | |
echo "::set-output name=release_id::$release_id" | |
- name: Upload to Latest Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
zip_file="packaged_artifacts/${{ matrix.target.zip_name }}" | |
release_id=${{ steps.get_release.outputs.release_id }} | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$zip_file" \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $zip_file)" |