attempt to autodeploy esphome firmware

This commit is contained in:
pszafer
2026-01-26 08:36:08 +01:00
parent f23f29f9a5
commit 914762dd6f
2 changed files with 207 additions and 5 deletions

194
.github/workflows/build-firmware.yml vendored Normal file
View File

@@ -0,0 +1,194 @@
name: Build ESPHome Firmware
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., 2026.1.2)'
required: true
default: '2026.1.2'
env:
ESPHOME_VERSION: "2024.12.4"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- yaml_file: boneio-dimmer_gen2_2rgbw-v0_1.yaml
chip_family: ESP32-S3
- yaml_file: boneio-dimmer_gen2_8ch-v0_1.yaml
chip_family: ESP32-S3
- yaml_file: boneio-32x10_lights_v0_7.yaml
chip_family: ESP32
- yaml_file: boneio-32x10_switches_v0_7.yaml
chip_family: ESP32
- yaml_file: boneio-24x16_switches_v0_7.yaml
chip_family: ESP32
- yaml_file: boneio-cover_v0_7.yaml
chip_family: ESP32
- yaml_file: boneio-cover_mix_lights_v0_7.yaml
chip_family: ESP32
- yaml_file: boneio-cover_mix_switches_v0_7.yaml
chip_family: ESP32
- yaml_file: boneio-8x10A_gen2_lights-v0_1.yaml
chip_family: ESP32-S3
- yaml_file: boneio-mosfet48_lights_v0_7.yaml
chip_family: ESP32
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install ESPHome
run: pip install esphome==${{ env.ESPHOME_VERSION }}
- name: Build firmware
run: esphome compile ${{ matrix.yaml_file }}
- name: Get firmware name from YAML
id: get_name
run: |
NAME=$(grep -m1 'name:' ${{ matrix.yaml_file }} | sed 's/.*name:\s*//' | tr -d ' ')
echo "firmware_name=$NAME" >> $GITHUB_OUTPUT
echo "chip_family=${{ matrix.chip_family }}" >> $GITHUB_OUTPUT
- name: Copy firmware to output
run: |
mkdir -p output
FIRMWARE_NAME="${{ steps.get_name.outputs.firmware_name }}"
cp .esphome/build/${FIRMWARE_NAME}/.pioenvs/${FIRMWARE_NAME}/firmware.factory.bin output/${FIRMWARE_NAME}.bin
- name: Upload firmware artifact
uses: actions/upload-artifact@v4
with:
name: firmware-${{ steps.get_name.outputs.firmware_name }}
path: output/*.bin
- name: Upload chip family info
run: echo "${{ matrix.chip_family }}" > output/${{ steps.get_name.outputs.firmware_name }}.chip
- name: Upload chip info artifact
uses: actions/upload-artifact@v4
with:
name: chip-${{ steps.get_name.outputs.firmware_name }}
path: output/*.chip
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download firmware artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: firmware-*
merge-multiple: true
- name: Download chip info artifacts
uses: actions/download-artifact@v4
with:
path: chip-info
pattern: chip-*
merge-multiple: true
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Prepare GitHub Pages content
run: |
mkdir -p gh-pages/firmware
cp artifacts/*.bin gh-pages/firmware/
# Generate manifest JSON files for ESP Web Tools
for bin in gh-pages/firmware/*.bin; do
FIRMWARE_NAME=$(basename "$bin" .bin)
CHIP_FAMILY="ESP32"
if [ -f "chip-info/${FIRMWARE_NAME}.chip" ]; then
CHIP_FAMILY=$(cat "chip-info/${FIRMWARE_NAME}.chip")
elif [[ "$FIRMWARE_NAME" == *"gen2"* ]]; then
CHIP_FAMILY="ESP32-S3"
fi
cat > gh-pages/${FIRMWARE_NAME}.json << EOF
{
"name": "boneIO ESPHome",
"version": "${{ steps.version.outputs.version }}",
"home_assistant_domain": "esphome",
"funding_url": "https://esphome.io/guides/supporters.html",
"new_install_prompt_erase": false,
"builds": [
{
"chipFamily": "${CHIP_FAMILY}",
"parts": [
{
"path": "firmware/${FIRMWARE_NAME}.bin",
"offset": 0
}
]
}
]
}
EOF
done
# Create version file
echo "${{ steps.version.outputs.version }}" > gh-pages/version.txt
# Create index with firmware list
cat > gh-pages/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head><title>boneIO Firmware</title></head>
<body>
<h1>boneIO ESPHome Firmware</h1>
<ul>
EOF
for bin in gh-pages/firmware/*.bin; do
NAME=$(basename "$bin" .bin)
echo "<li><a href=\"${NAME}.json\">${NAME}</a></li>" >> gh-pages/index.html
done
cat >> gh-pages/index.html << 'EOF'
</ul>
</body>
</html>
EOF
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
force_orphan: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: Firmware v${{ steps.version.outputs.version }}
files: artifacts/*.bin
generate_release_notes: true