Unmigrate esphome hub75 lib (#127) #210
Workflow file for this run
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: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - "**" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ubuntu-latest | |
| container: espressif/idf:release-v5.5 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - tidbyt-gen1 | |
| - tidbyt-gen1_swap | |
| - tidbyt-gen2 | |
| - tronbyt-s3 | |
| - tronbyt-s3-wide | |
| - pixoticker | |
| - matrixportal-s3 | |
| - matrixportal-s3-waveshare | |
| env: | |
| IDF_CCACHE_ENABLE: "1" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Git Safe Directory | |
| run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
| - name: ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ccache | |
| key: ${{ runner.os }}-ccache-${{ matrix.target }}-${{ hashFiles('**/sdkconfig.defaults*') }} | |
| restore-keys: | | |
| ${{ runner.os }}-ccache-${{ matrix.target }}- | |
| - name: Generate version header | |
| run: | | |
| if git describe --tags --abbrev=0 2>/dev/null; then | |
| VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//') | |
| else | |
| VERSION=$(git describe --always --dirty) | |
| fi | |
| echo "Firmware version: $VERSION" | |
| cat > main/version.h << EOF | |
| // Auto-generated file - DO NOT EDIT | |
| // Generated by GitHub Actions | |
| #pragma once | |
| #define FIRMWARE_VERSION "$VERSION" | |
| EOF | |
| - name: Build Target | |
| run: | | |
| . $IDF_PATH/export.sh | |
| target="${{ matrix.target }}" | |
| echo "--------------------------------------" | |
| echo "Building target: $target" | |
| echo "--------------------------------------" | |
| # Determine chip type based on target | |
| case "$target" in | |
| tronbyt-s3*|matrixportal-s3*) | |
| chip="esp32s3" | |
| ;; | |
| *) | |
| chip="esp32" | |
| ;; | |
| esac | |
| BUILD_DIR="build_$target" | |
| # Set the target and apply sdkconfig defaults | |
| idf.py -B "$BUILD_DIR" -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.$target" set-target "$chip" | |
| idf.py -B "$BUILD_DIR" build | |
| if [ ! -f "$BUILD_DIR/firmware.bin" ]; then | |
| echo "❌ Failed to generate firmware for $target" | |
| exit 1 | |
| fi | |
| # Generate merged binary | |
| echo "Generating merged binary for $chip..." | |
| # Run esptool from within the build directory so relative paths in flash_args work | |
| (cd "$BUILD_DIR" && python -m esptool --chip "$chip" merge_bin -o "merged_firmware.bin" @flash_args) | |
| # Rename for artifact upload | |
| mv "$BUILD_DIR/firmware.bin" "${target}_firmware.bin" | |
| mv "$BUILD_DIR/merged_firmware.bin" "${target}_merged.bin" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.target }}_firmware | |
| path: | | |
| ${{ matrix.target }}_firmware.bin | |
| ${{ matrix.target }}_merged.bin | |
| if-no-files-found: error | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Download All Artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: release-artifacts | |
| pattern: '*_firmware' | |
| merge-multiple: true | |
| - name: Display Artifacts | |
| run: ls -R release-artifacts/ | |
| - name: Create Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ github.ref_name }} | |
| run: | | |
| # Collect all artifacts and pass them to gh release create as positional arguments | |
| gh release create "$tag" \ | |
| --repo="${GITHUB_REPOSITORY}" \ | |
| --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ | |
| --generate-notes \ | |
| $(find release-artifacts -type f -print0 | xargs -0) |