yaml: fix the indentification, adapt to host only

Dieser Commit ist enthalten in:
tom committed 2026-10-19 15:02:16 +02:00
1 Ursprung 157c87fe89
Commit f16a243e3f
1 Datei geändert
+189 -181
+189 -181
Datei anzeigen
@@ -1,4 +1,4 @@
name: Automated CI Build of FoxMesh name: Build of FoxMesh
on: on:
push: push:
@@ -19,113 +19,121 @@ jobs:
contents: write # We want also create official Releases contents: write # We want also create official Releases
steps: steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
# 1. Checkout the target branch
- name: Checkout Target branch
uses: actions/checkout@v7
with:
ref: ${{ github.event.inputs.target_branch || github.ref }}
# 2. Extract Git and Date Metadata for the dynamic artifact filename # 1. Checkout the target branch
- name: Generate Dynamic Artifact Metadata - name: Checkout Target branch
id: meta uses: actions/checkout@v7
run: | with:
# Get current date in YYYYMMDD format ref: ${{ github.event.inputs.target_branch || github.ref }}
echo "CURRENT_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
# Get short 7-character git commit hash # 2. Extract Git and Date Metadata for the dynamic artifact filename
echo "GIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Generate Dynamic Artifact Metadata
id: meta
run: |
# Get current date in YYYYMMDD format
echo "CURRENT_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
# Extract and sanitize branch name (replace slashes and special characters with dashes) # Get short 7-character git commit hash
RAW_BRANCH=${{ github.event.inputs.target_branch || github.ref_name }} echo "GIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
CLEAN_BRANCH=$(echo "$RAW_BRANCH" | sed 's/[^a-zA-Z0-9.\-]/_§/g' | sed 's|§|-|g' | sed 's|_||g')
echo "GIT_BRANCH=$CLEAN_BRANCH" >> $GITHUB_ENV
# 3. Set up Python environment # Extract and sanitize branch name (replace slashes and special characters with dashes)
- name: Set up Python 3.x RAW_BRANCH=${{ github.event.inputs.target_branch || github.ref_name }}
uses: actions/setup-python@v7 CLEAN_BRANCH=$(echo "$RAW_BRANCH" | sed 's/[^a-zA-Z0-9.\-]/_§/g' | sed 's|§|-|g' | sed 's|_||g')
with: echo "GIT_BRANCH=$CLEAN_BRANCH" >> $GITHUB_ENV
python-version: '3.x'
# 4. Cache global PlatformIO directories, uses a dynamic key based on platformio.ini #3 Python alread installed
- name: Cache PlatformIO - name: Show Python Version
uses: actions/cache@v6 run: python --version
with:
path: |
~/.cache/pio
~/.platformio
.pio
key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-
# 5. Install PlatformIO Core and the required intelhex extension in a single, quiet command # 4. Cache global PlatformIO directories, uses a dynamic key based on platformio.ini
- name: Install PlatformIO Core - name: Cache PlatformIO
run: python -m pip install --quiet --upgrade pip platformio intelhex uses: actions/cache@v6
with:
path: |
.platformio
.pio
key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-
# 6. Install ESP32 Platform SDK - name: PlatformIO in venv installieren
- name: Install ESP32 platform run: |
run: pio pkg install --silent --global --platform espressif32 python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --quiet --upgrade pip platformio intelhex
# Ab hier steht platformio in diesem Schritt zur Verfügung
pio --version
# Fügt den Pfad absolut dem GitHub/Gitea-Pfad hinzu:
echo "$PWD/.venv/bin" >> $GITHUB_PATH
# 7. Compile the Project # 5. Install PlatformIO Core and the required intelhex extension in a single, quiet command
- name: Compile the Project # - name: Install PlatformIO Core
run: pio run # run: python -m pip install --quiet --upgrade pip platformio intelhex
# 8. Dynamically create the smart flashing scripts next to the T-Beam binary # 6. Install ESP32 Platform SDK
# with optional bootloader detection and group check # - name: Install ESP32 platform
# the table of flash addresses usually found at /partitions-4MB-safeboot.csv # run: pio pkg install --silent --global --platform espressif32
- name: Create Desktop Flashing Scripts
run: |
# ----------------------------------------------------------------------
# 0. Flash Address Configuration ← edit here to change the layout
# ----------------------------------------------------------------------
FLASH_BOOTLOADER_ADDR="0x1000"
FLASH_PARTITIONS_ADDR="0x8000"
FLASH_OTADATA_ADDR="0xE000"
FLASH_SAFEBOOT_ADDR="0x10000"
FLASH_FIRMWARE_ADDR="0x10000"
# ---------------------------------------------------------------------- # 7. Compile the Project
# 1. Universal Linux Shell Script - name: Compile the Project
# ---------------------------------------------------------------------- run: pio run
cat << 'EOF' > flash_esp32_board.sh
#!/usr/bin/env bash
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${YELLOW}=== FoxMesh Universal ESP32 Flashing Script ===${NC}" # 8. Dynamically create the smart flashing scripts next to the T-Beam binary
# with optional bootloader detection and group check
# the table of flash addresses usually found at /partitions-4MB-safeboot.csv
- name: Create Desktop Flashing Scripts
run: |
# ----------------------------------------------------------------------
# 0. Flash Address Configuration ← edit here to change the layout
# ----------------------------------------------------------------------
FLASH_BOOTLOADER_ADDR="0x1000"
FLASH_PARTITIONS_ADDR="0x8000"
FLASH_OTADATA_ADDR="0xE000"
FLASH_SAFEBOOT_ADDR="0x10000"
FLASH_FIRMWARE_ADDR="0x10000"
if ! command -v esptool &> /dev/null; then # ----------------------------------------------------------------------
# 1. Universal Linux Shell Script
# ----------------------------------------------------------------------
cat << 'EOF' > flash_esp32_board.sh
#!/usr/bin/env bash
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${YELLOW}=== FoxMesh Universal ESP32 Flashing Script ===${NC}"
if ! command -v esptool &> /dev/null; then
echo -e "${RED}Error: esptool is not installed.${NC}" echo -e "${RED}Error: esptool is not installed.${NC}"
echo "Please install it via your package manager or pip: 'pip install esptool'" echo "Please install it via your package manager or pip: 'pip install esptool'"
echo "Option Linux Arch: 'sudo pacman -Sy && sudo pacman -S extra-testing/esptool'" echo "Option Linux Arch: 'sudo pacman -Sy && sudo pacman -S extra-testing/esptool'"
exit 1 exit 1
fi fi
FIRMWARE="firmware.bin" FIRMWARE="firmware.bin"
# Firmware File # Firmware File
if [ ! -f "$FIRMWARE" ]; then if [ ! -f "$FIRMWARE" ]; then
echo -e "${RED}Error: No matching firmware binary found in this folder!${NC}" echo -e "${RED}Error: No matching firmware binary found in this folder!${NC}"
exit 1 exit 1
fi fi
echo -e "${GREEN}Selected Firmware:${NC} $FIRMWARE ($BOARD_NAME)" echo -e "${GREEN}Selected Firmware:${NC} $FIRMWARE ($BOARD_NAME)"
PORT=$(ls /dev/ttyUSB* /dev/ttyACM* 2>/dev/null | head -n 1) PORT=$(ls /dev/ttyUSB* /dev/ttyACM* 2>/dev/null | head -n 1)
if [ -z "$PORT" ]; then if [ -z "$PORT" ]; then
echo -e "${RED}Error: No connected ESP32 Board (ttyUSB/ttyACM) found!${NC}" echo -e "${RED}Error: No connected ESP32 Board (ttyUSB/ttyACM) found!${NC}"
exit 1 exit 1
fi fi
echo -e "${GREEN}Detected Board on port:${NC} $PORT" echo -e "${GREEN}Detected Board on port:${NC} $PORT"
# Dynamic Permission Check: Determine required group for the specific TTY device # Dynamic Permission Check: Determine required group for the specific TTY device
REQUIRED_GROUP=$(stat -c '%G' "$PORT") REQUIRED_GROUP=$(stat -c '%G' "$PORT")
if [ "$REQUIRED_GROUP" != "root" ]; then if [ "$REQUIRED_GROUP" != "root" ]; then
if ! groups "$USER" | grep -q "\b${REQUIRED_GROUP}\b"; then if ! groups "$USER" | grep -q "\b${REQUIRED_GROUP}\b"; then
echo -e "${RED}Error: You do not have permissions to access $PORT.${NC}" echo -e "${RED}Error: You do not have permissions to access $PORT.${NC}"
echo -e "The device belongs to the group: ${YELLOW}$REQUIRED_GROUP${NC}" echo -e "The device belongs to the group: ${YELLOW}$REQUIRED_GROUP${NC}"
@@ -134,107 +142,107 @@ jobs:
echo -e "After running the command, please log out and log back in for the changes to take effect." echo -e "After running the command, please log out and log back in for the changes to take effect."
exit 1 exit 1
fi fi
fi fi
# Build flash arguments from the address table (only include files that exist) # Build flash arguments from the address table (only include files that exist)
FLASH_ARGS="" FLASH_ARGS=""
if [ -f "bootloader.bin" ]; then if [ -f "bootloader.bin" ]; then
FLASH_ARGS="$FLASH_ARGS __BOOTLOADER_ADDR__ bootloader.bin" FLASH_ARGS="$FLASH_ARGS __BOOTLOADER_ADDR__ bootloader.bin"
fi fi
if [ -f "partitions.bin" ]; then if [ -f "partitions.bin" ]; then
FLASH_ARGS="$FLASH_ARGS __PARTITIONS_ADDR__ partitions.bin" FLASH_ARGS="$FLASH_ARGS __PARTITIONS_ADDR__ partitions.bin"
fi fi
if [ -f "otadata.bin" ]; then if [ -f "otadata.bin" ]; then
FLASH_ARGS="$FLASH_ARGS __OTADATA_ADDR__ otadata.bin" FLASH_ARGS="$FLASH_ARGS __OTADATA_ADDR__ otadata.bin"
fi fi
if [ -f "safeboot.bin" ]; then if [ -f "safeboot.bin" ]; then
FLASH_ARGS="$FLASH_ARGS __SAFEBOOT_ADDR__ safeboot.bin" FLASH_ARGS="$FLASH_ARGS __SAFEBOOT_ADDR__ safeboot.bin"
fi fi
FLASH_ARGS="$FLASH_ARGS __FIRMWARE_ADDR__ $FIRMWARE" FLASH_ARGS="$FLASH_ARGS __FIRMWARE_ADDR__ $FIRMWARE"
echo -e "${GREEN}Flashing:${NC}$FLASH_ARGS" echo -e "${GREEN}Flashing:${NC}$FLASH_ARGS"
esptool --chip esp32 --port "$PORT" --baud 921600 write-flash -z $FLASH_ARGS esptool --chip esp32 --port "$PORT" --baud 921600 write-flash -z $FLASH_ARGS
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}=== Success! $BOARD_NAME successfully updated ===${NC}" echo -e "${GREEN}=== Success! $BOARD_NAME successfully updated ===${NC}"
else else
echo -e "${RED}=== Flash failed! ===${NC}" echo -e "${RED}=== Flash failed! ===${NC}"
exit 1 exit 1
fi fi
EOF EOF
# Substitute address placeholders with configured hex values # Substitute address placeholders with configured hex values
sed -i \ sed -i \
-e "s|__BOOTLOADER_ADDR__|${FLASH_BOOTLOADER_ADDR}|g" \ -e "s|__BOOTLOADER_ADDR__|${FLASH_BOOTLOADER_ADDR}|g" \
-e "s|__PARTITIONS_ADDR__|${FLASH_PARTITIONS_ADDR}|g" \ -e "s|__PARTITIONS_ADDR__|${FLASH_PARTITIONS_ADDR}|g" \
-e "s|__OTADATA_ADDR__|${FLASH_OTADATA_ADDR}|g" \ -e "s|__OTADATA_ADDR__|${FLASH_OTADATA_ADDR}|g" \
-e "s|__SAFEBOOT_ADDR__|${FLASH_SAFEBOOT_ADDR}|g" \ -e "s|__SAFEBOOT_ADDR__|${FLASH_SAFEBOOT_ADDR}|g" \
-e "s|__FIRMWARE_ADDR__|${FLASH_FIRMWARE_ADDR}|g" \ -e "s|__FIRMWARE_ADDR__|${FLASH_FIRMWARE_ADDR}|g" \
flash_esp32_board.sh flash_esp32_board.sh
chmod +x flash_esp32_board.sh chmod +x flash_esp32_board.sh
# ---------------------------------------------------- # ----------------------------------------------------
# 2. Universal Windows Batch Script # 2. Universal Windows Batch Script
# ---------------------------------------------------- # ----------------------------------------------------
cat << 'EOF' > flash_esp32_board.bat cat << 'EOF' > flash_esp32_board.bat
@echo off @echo off
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
echo =================================================== echo ===================================================
echo === FoxMesh Universal ESP32 Windows Flashing ====== echo === FoxMesh Universal ESP32 Windows Flashing ======
echo =================================================== echo ===================================================
set "FIRMWARE=firmware.bin" set "FIRMWARE=firmware.bin"
if not exist "!FIRMWARE!" ( if not exist "!FIRMWARE!" (
echo [ERROR] No matching firmware binary found in this folder! echo [ERROR] No matching firmware binary found in this folder!
pause pause
exit /b 1 exit /b 1
) )
echo [INFO] Selected Firmware: %FIRMWARE% (%BOARD_NAME%) echo [INFO] Selected Firmware: %FIRMWARE% (%BOARD_NAME%)
set "COMPORT=" set "COMPORT="
for /f "tokens=2 delims=()" %%A in ('wmic path Win32_PnPEntity get Name ^| findstr /i "COM" ^| findstr /i "Silicon CP210 CH340 CH9102 USB-to-UART"') do set "COMPORT=%%A" for /f "tokens=2 delims=()" %%A in ('wmic path Win32_PnPEntity get Name ^| findstr /i "COM" ^| findstr /i "Silicon CP210 CH340 CH9102 USB-to-UART"') do set "COMPORT=%%A"
if "%COMPORT%"=="" ( if "%COMPORT%"=="" (
for /f "tokens=2 delims=()" %%A in ('wmic path Win32_PnPEntity get Name ^| findstr /i "(COM"') do set "COMPORT=%%A" for /f "tokens=2 delims=()" %%A in ('wmic path Win32_PnPEntity get Name ^| findstr /i "(COM"') do set "COMPORT=%%A"
) )
if "%COMPORT%"=="" ( if "%COMPORT%"=="" (
echo [ERROR] No ESP32 Board or USB-UART bridge detected! echo [ERROR] No ESP32 Board or USB-UART bridge detected!
pause
exit /b 1
)
echo [INFO] Detected Board on port: %COMPORT%
set "FLASH_ARGS="
if exist "bootloader.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __BOOTLOADER_ADDR__ bootloader.bin"
)
if exist "partitions.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __PARTITIONS_ADDR__ partitions.bin"
)
if exist "otadata.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __OTADATA_ADDR__ otadata.bin"
)
if exist "safeboot.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __SAFEBOOT_ADDR__ safeboot.bin"
)
set "FLASH_ARGS=!FLASH_ARGS! __FIRMWARE_ADDR__ %FIRMWARE%"
echo [INFO] Flashing: !FLASH_ARGS!
esptool --chip esp32 --port %COMPORT% --baud 921600 write-flash -z !FLASH_ARGS!
if %ERRORLEVEL% EQU 0 (
echo === SUCCESS! Flash operation successfully completed ===
) else (
echo [ERROR] Flash failed!
pause
exit /b 1
)
pause pause
exit /b 1 EOF
)
echo [INFO] Detected Board on port: %COMPORT%
set "FLASH_ARGS=" # Substitute address placeholders with configured hex values
if exist "bootloader.bin" ( sed -i \
set "FLASH_ARGS=!FLASH_ARGS! __BOOTLOADER_ADDR__ bootloader.bin"
)
if exist "partitions.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __PARTITIONS_ADDR__ partitions.bin"
)
if exist "otadata.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __OTADATA_ADDR__ otadata.bin"
)
if exist "safeboot.bin" (
set "FLASH_ARGS=!FLASH_ARGS! __SAFEBOOT_ADDR__ safeboot.bin"
)
set "FLASH_ARGS=!FLASH_ARGS! __FIRMWARE_ADDR__ %FIRMWARE%"
echo [INFO] Flashing: !FLASH_ARGS!
esptool --chip esp32 --port %COMPORT% --baud 921600 write-flash -z !FLASH_ARGS!
if %ERRORLEVEL% EQU 0 (
echo === SUCCESS! Flash operation successfully completed ===
) else (
echo [ERROR] Flash failed!
pause
exit /b 1
)
pause
EOF
# Substitute address placeholders with configured hex values
sed -i \
-e "s|__BOOTLOADER_ADDR__|${FLASH_BOOTLOADER_ADDR}|g" \ -e "s|__BOOTLOADER_ADDR__|${FLASH_BOOTLOADER_ADDR}|g" \
-e "s|__PARTITIONS_ADDR__|${FLASH_PARTITIONS_ADDR}|g" \ -e "s|__PARTITIONS_ADDR__|${FLASH_PARTITIONS_ADDR}|g" \
-e "s|__OTADATA_ADDR__|${FLASH_OTADATA_ADDR}|g" \ -e "s|__OTADATA_ADDR__|${FLASH_OTADATA_ADDR}|g" \
@@ -242,27 +250,27 @@ jobs:
-e "s|__FIRMWARE_ADDR__|${FLASH_FIRMWARE_ADDR}|g" \ -e "s|__FIRMWARE_ADDR__|${FLASH_FIRMWARE_ADDR}|g" \
flash_esp32_board.bat flash_esp32_board.bat
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# 3. Gather binaries and scripts into target directory for structural packaging # 3. Gather binaries and scripts into target directory for structural packaging
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
mkdir -p deploy_package mkdir -p deploy_package
BUILD_OUTPUT=".pio/build/ttgo-lora32-v21" BUILD_OUTPUT=".pio/build/ttgo-lora32-v21"
# Copy binaries only if they exist # Copy binaries only if they exist
[ -f "$BUILD_OUTPUT/firmware.bin" ] && cp "$BUILD_OUTPUT/firmware.bin" ./deploy_package/ [ -f "$BUILD_OUTPUT/firmware.bin" ] && cp "$BUILD_OUTPUT/firmware.bin" ./deploy_package/
[ -f "$BUILD_OUTPUT/bootloader.bin" ] && cp "$BUILD_OUTPUT/bootloader.bin" ./deploy_package/ [ -f "$BUILD_OUTPUT/bootloader.bin" ] && cp "$BUILD_OUTPUT/bootloader.bin" ./deploy_package/
[ -f "$BUILD_OUTPUT/partitions.bin" ] && cp "$BUILD_OUTPUT/partitions.bin" ./deploy_package/ [ -f "$BUILD_OUTPUT/partitions.bin" ] && cp "$BUILD_OUTPUT/partitions.bin" ./deploy_package/
[ -f "$BUILD_OUTPUT/otadata.bin" ] && cp "$BUILD_OUTPUT/otadata.bin" ./deploy_package/ [ -f "$BUILD_OUTPUT/otadata.bin" ] && cp "$BUILD_OUTPUT/otadata.bin" ./deploy_package/
[ -f "$BUILD_OUTPUT/safeboot.bin" ] && cp "$BUILD_OUTPUT/safeboot.bin" ./deploy_package/ [ -f "$BUILD_OUTPUT/safeboot.bin" ] && cp "$BUILD_OUTPUT/safeboot.bin" ./deploy_package/
# Move flash scripts into the deployment directory # Move flash scripts into the deployment directory
mv flash_esp32_board.sh ./deploy_package/ mv flash_esp32_board.sh ./deploy_package/
mv flash_esp32_board.bat ./deploy_package/ mv flash_esp32_board.bat ./deploy_package/
# 9. Dynamic Artifact Upload: FoxMesh-branch-date-hash.zip # 9. Dynamic Artifact Upload: FoxMesh-branch-date-hash.zip
- name: Upload Compiled Firmware Package - name: Upload Compiled Firmware Package
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v7
with: with:
name: FoxMesh-${{ env.GIT_BRANCH }}-${{ env.CURRENT_DATE }}-${{ env.GIT_HASH }} name: FoxMesh-${{ env.GIT_BRANCH }}-${{ env.CURRENT_DATE }}-${{ env.GIT_HASH }}
path: deploy_package/ path: deploy_package/
retention-days: 10 # Artifacts will be automatically deleted after 10 days retention-days: 10 # Artifacts will be automatically deleted after 10 days