diff --git a/.github/workflows/foxmesh-ci.yml b/.github/workflows/foxmesh-ci.yml index bcd71f2..6d15925 100644 --- a/.github/workflows/foxmesh-ci.yml +++ b/.github/workflows/foxmesh-ci.yml @@ -27,13 +27,28 @@ jobs: with: ref: ${{ github.event.inputs.target_branch || github.ref }} - # 2. Set up Python environment + # 2. Extract Git and Date Metadata for the dynamic artifact filename + - name: Generate Dynamic Artifact Metadata + id: meta + run: | + # Get current date in YYYYMMDD format + echo "CURRENT_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV + + # Get short 7-character git commit hash + echo "GIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + + # Extract and sanitize branch name (replace slashes and special characters with dashes) + RAW_BRANCH=${{ github.event.inputs.target_branch || github.ref_name }} + 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 - name: Set up Python 3.x uses: actions/setup-python@v7 with: python-version: '3.x' - # 3. Cache global PlatformIO directories, uses a dynamic key based on platformio.ini + # 4. Cache global PlatformIO directories, uses a dynamic key based on platformio.ini - name: Cache PlatformIO uses: actions/cache@v6 with: @@ -45,17 +60,19 @@ jobs: restore-keys: | ${{ runner.os }}-pio- - # 4. Install PlatformIO Core and the required intelhex extension in a single, quiet command + # 5. Install PlatformIO Core and the required intelhex extension in a single, quiet command - name: Install PlatformIO Core run: python -m pip install --quiet --upgrade pip platformio intelhex + # 6. Install ESP32 Platform SDK - name: Install ESP32 platform run: pio pkg install --silent --global --platform espressif32 + # 7. Compile the Project - name: Compile the Project run: pio run - # 11. Dynamically create the smart flashing scripts next to the T-Beam binary + # 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 @@ -79,20 +96,20 @@ jobs: YELLOW='\033[1;33m' NC='\033[0m' - echo -e "${YELLOW}=== MeshCom Universal ESP32 Flashing Script ===${NC}" + 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 "Please install it via your package manager or pip: 'pip install esptool'" - echo "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 fi - FIRMWARE = "firmware.bin" + FIRMWARE="firmware.bin" # Firmware File - if [ ! -f "firmware.bin" ]; then + if [ ! -f "$FIRMWARE" ]; then echo -e "${RED}Error: No matching firmware binary found in this folder!${NC}" exit 1 fi @@ -162,17 +179,12 @@ jobs: @echo off setlocal enabledelayedexpansion echo =================================================== - echo === MeshCom Universal ESP32 Windows Flashing ====== + echo === FoxMesh Universal ESP32 Windows Flashing ====== echo =================================================== set "FIRMWARE=firmware.bin" - set "BOARD_NAME=" - if exist "firmeware.bin" ( - set "BOARD_NAME=ESP32" - ) - - if "%FIRMWARE%"="" ( + if not exist "!FIRMWARE!" ( echo [ERROR] No matching firmware binary found in this folder! pause exit /b 1 @@ -211,12 +223,14 @@ jobs: esptool --chip esp32 --port %COMPORT% --baud 921600 write-flash -z !FLASH_ARGS! if %ERRORLEVEL% EQU 0 ( - echo === SUCCESS! %BOARD_NAME% successfully updated === + echo === SUCCESS! Flash operation successfully completed === ) else ( echo [ERROR] Flash failed! + pause + exit /b 1 ) pause - EOF +EOF # Substitute address placeholders with configured hex values sed -i \ @@ -225,26 +239,29 @@ jobs: -e "s|__OTADATA_ADDR__|${FLASH_OTADATA_ADDR}|g" \ -e "s|__SAFEBOOT_ADDR__|${FLASH_SAFEBOOT_ADDR}|g" \ -e "s|__FIRMWARE_ADDR__|${FLASH_FIRMWARE_ADDR}|g" \ - flash_esp32_board.bat + flash_esp32_board.bat - # ---------------------------------------------------- - # 3. Distribute Scripts into target build directories - # ---------------------------------------------------- - # mkdir -p .pio/build/ttgo_tbeam - # mkdir -p .pio/build/ttgo-lora32-v21 + # ----------------------------------------------------------------------------- + # 3. Gather binaries and scripts into target directory for structural packaging + # ----------------------------------------------------------------------------- + mkdir -p deploy_package + BUILD_OUTPUT=".pio/build/ttgo-lora32-v21" - # cp flash_esp32_board.sh .pio/build/ttgo_tbeam/ - # cp flash_esp32_board.bat .pio/build/ttgo_tbeam/ + # Copy binaries only if they exist + [ -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/partitions.bin" ] && cp "$BUILD_OUTPUT/partitions.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/ + + # Move flash scripts into the deployment directory + mv flash_esp32_board.sh ./deploy_package/ + mv flash_esp32_board.bat ./deploy_package/ - # cp flash_esp32_board.sh .pio/build/ttgo-lora32-v21/ - # cp flash_esp32_board.bat .pio/build/ttgo-lora32-v21/ - - # 12. Upload all compiled firmware artifacts with zip compression - - name: Upload Compiled Firmware Artifacts + # 9. Dynamic Artifact Upload: FoxMesh-branch-date-hash.zip + - name: Upload Compiled Firmware Package uses: actions/upload-artifact@v7 with: - name: firmware-build-${{ github.event.inputs.target_branch || github.ref_name }} - path: | - .pio/build/**/*.bin - # flash_esp32_board.* + name: FoxMesh-${{ env.GIT_BRANCH }}-${{ env.CURRENT_DATE }}-${{ env.GIT_HASH }} + path: deploy_package/ retention-days: 10 # Artifacts will be automatically deleted after 10 days