Bump actions/configure-pages from 5 to 6 #73
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 ESP-Hosted Firmware | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'ESP-Hosted version to build' | |
| type: string | |
| default: '2.7.0' | |
| release: | |
| description: 'Create a release' | |
| type: boolean | |
| default: true | |
| env: | |
| ESP_IDF_VERSION: v5.5.3 | |
| ESP_HOSTED_VERSION: ${{ inputs.version || '2.7.0' }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: espressif/idf:v5.5.1 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - esp32 | |
| - esp32c5 | |
| - esp32c6 | |
| - esp32c61 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - 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@v7 | |
| 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@v8 | |
| 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: | |
| matrix: | |
| target: | |
| - esp32 | |
| - esp32c5 | |
| - esp32c6 | |
| - esp32c61 | |
| steps: | |
| - name: Generate manifest | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TARGET="${{ matrix.target }}" | |
| REPO="${{ github.repository }}" | |
| REPO_OWNER=$(echo "$REPO" | cut -d'/' -f1) | |
| REPO_NAME=$(echo "$REPO" | cut -d'/' -f2) | |
| BASE_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}" | |
| # 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="${BASE_URL}/${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 | |
| deploy-pages: | |
| needs: manifest | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Download all releases and manifests | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p public/manifest | |
| # Download manifests | |
| gh release download manifest \ | |
| --repo "${{ github.repository }}" \ | |
| --pattern "*.json" \ | |
| --dir public/manifest || true | |
| # Get all release tags (exclude manifest) | |
| TAGS=$(gh release list --repo "${{ github.repository }}" --json tagName -q '.[].tagName' | grep -v '^manifest$') | |
| for TAG in $TAGS; do | |
| echo "Downloading $TAG..." | |
| mkdir -p "public/$TAG" | |
| gh release download "$TAG" \ | |
| --repo "${{ github.repository }}" \ | |
| --pattern "*.bin" \ | |
| --dir "public/$TAG" || true | |
| done | |
| - name: Create index.html | |
| run: | | |
| REPO_OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1) | |
| REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) | |
| BASE_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}" | |
| cat > public/index.html << 'HEADER' | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>ESP-Hosted Firmware</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; margin: 40px; max-width: 900px; } | |
| h1 { color: #333; } | |
| h2 { color: #555; margin-top: 30px; border-bottom: 1px solid #ddd; padding-bottom: 5px; } | |
| h3 { color: #666; margin-top: 20px; } | |
| ul { list-style-type: none; padding: 0; } | |
| li { margin: 8px 0; } | |
| a { color: #0366d6; text-decoration: none; } | |
| a:hover { text-decoration: underline; } | |
| code { font-family: monospace; font-size: 0.85em; background: #f6f8fa; padding: 2px 6px; border-radius: 3px; } | |
| .latest { background: #28a745; color: white; padding: 2px 8px; border-radius: 3px; font-size: 0.8em; margin-left: 10px; } | |
| .manifest-section { background: #f8f9fa; padding: 15px; border-radius: 5px; margin-bottom: 30px; } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>ESP-Hosted Firmware</h1> | |
| <p>Pre-built ESP-Hosted firmware binaries for ESPHome.</p> | |
| <div class="manifest-section"> | |
| <h3>Manifests (JSON)</h3> | |
| <p>Machine-readable manifests with all versions, URLs, and SHA256 checksums:</p> | |
| <ul> | |
| HEADER | |
| for manifest in public/manifest/*.json; do | |
| if [ -f "$manifest" ]; then | |
| filename=$(basename "$manifest") | |
| target="${filename%.json}" | |
| echo " <li><a href=\"manifest/${filename}\">${target}</a> - <code>${BASE_URL}/manifest/${filename}</code></li>" >> public/index.html | |
| fi | |
| done | |
| cat >> public/index.html << 'MIDDLE' | |
| </ul> | |
| </div> | |
| <h2>Releases</h2> | |
| MIDDLE | |
| FIRST=true | |
| for dir in $(ls -d public/v* 2>/dev/null | sort -V -r); do | |
| TAG=$(basename "$dir") | |
| echo " <h3>$TAG" >> public/index.html | |
| if [ "$FIRST" = true ]; then | |
| echo '<span class="latest">Latest</span>' >> public/index.html | |
| FIRST=false | |
| fi | |
| echo "</h3>" >> public/index.html | |
| echo " <ul>" >> public/index.html | |
| for file in "$dir"/*.bin; do | |
| if [ -f "$file" ]; then | |
| filename=$(basename "$file") | |
| echo " <li><a href=\"${TAG}/${filename}\">${filename}</a> - <code>${BASE_URL}/${TAG}/${filename}</code></li>" >> public/index.html | |
| fi | |
| done | |
| echo " </ul>" >> public/index.html | |
| done | |
| cat >> public/index.html << 'FOOTER' | |
| </body> | |
| </html> | |
| FOOTER | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v6 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: public | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |