Skip to content

Build ESP-Hosted Firmware #3

Build ESP-Hosted Firmware

Build ESP-Hosted Firmware #3

Workflow file for this run

name: Build ESP-Hosted Firmware
on:
push:
branches: [main]
tags: ['v*']
pull_request:
workflow_dispatch:
inputs:
version:
description: 'ESP-Hosted-MCU version to build'
type: string
default: '2.7.3'
release:
description: 'Create a release'
type: boolean
default: true
env:
ESP_IDF_VERSION: v5.5.1
ESP_HOSTED_VERSION: ${{ inputs.version || '2.7.3' }}
jobs:
build:
runs-on: ubuntu-latest
container:
image: espressif/idf:v5.5.1
strategy:
fail-fast: false
matrix:
target:
- esp32
# - esp32s2
- esp32s3
- esp32c2
- esp32c3
- esp32c5
- esp32c6
- esp32c61
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create project from esp_hosted slave example
run: |
. $IDF_PATH/export.sh
idf.py create-project-from-example "espressif/esp_hosted==${{ env.ESP_HOSTED_VERSION }}:slave"
- name: Build firmware
working-directory: slave
run: |
. $IDF_PATH/export.sh
idf.py set-target ${{ matrix.target }}
idf.py build
- name: Prepare artifacts
run: |
mkdir -p artifacts
cp slave/build/network_adapter.bin artifacts/network_adapter_${{ matrix.target }}.bin
sha256sum artifacts/network_adapter_${{ matrix.target }}.bin > artifacts/network_adapter_${{ matrix.target }}.bin.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: firmware-${{ matrix.target }}
path: artifacts/
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || inputs.release
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: firmware
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.ESP_HOSTED_VERSION }}
files: firmware/*
generate_release_notes: true
manifest:
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
target:
- esp32
# - esp32s2
- esp32s3
- esp32c2
- esp32c3
- esp32c5
- esp32c6
- esp32c61
steps:
- name: Generate manifest
env:
GH_TOKEN: ${{ github.token }}
run: |
TARGET="${{ matrix.target }}"
REPO="${{ github.repository }}"
# Get all release tags
TAGS=$(gh release list --repo "$REPO" --json tagName -q '.[].tagName')
# Build manifest using jq
echo '{"versions":[]}' > manifest.json
for TAG in $TAGS; do
# Skip manifest tag
if [ "$TAG" = "manifest" ]; then
continue
fi
VERSION="${TAG#v}"
SHA256_FILE="network_adapter_${TARGET}.bin.sha256"
# Download SHA256 file using gh CLI (handles auth properly)
if gh release download "$TAG" --repo "$REPO" --pattern "$SHA256_FILE" --clobber 2>/dev/null; then
SHA256=$(awk '{print $1}' "$SHA256_FILE")
rm -f "$SHA256_FILE"
if [ -n "$SHA256" ] && [ ${#SHA256} -eq 64 ]; then
BIN_URL="https://github.com/${REPO}/releases/download/${TAG}/network_adapter_${TARGET}.bin"
# Add to manifest using jq
jq --arg ver "$VERSION" --arg url "$BIN_URL" --arg sha "$SHA256" \
'.versions += [{"version": $ver, "url": $url, "sha256": $sha}]' \
manifest.json > tmp.json && mv tmp.json manifest.json
fi
fi
done
# Sort versions descending (newest first)
jq '.versions |= sort_by(.version | split(".") | map(tonumber)) | .versions |= reverse' \
manifest.json > ${TARGET}.json
- name: Upload manifest to release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create manifest release if it doesn't exist
gh release view manifest --repo "${{ github.repository }}" >/dev/null 2>&1 || \
gh release create manifest --repo "${{ github.repository }}" --title "Firmware Manifests" --notes "JSON manifests listing all firmware versions for each target."
gh release upload manifest \
--repo "${{ github.repository }}" \
--clobber \
${{ matrix.target }}.json