Skip to content

Commit 3e66e8f

Browse files
committed
🚀 Add ESP32 Web Tools integration and automated build pipeline
Features: ✅ GitHub Actions workflows for release and development builds ✅ Automated ESP32 Web Tools manifest generation ✅ Cross-platform build scripts (bash + batch) ✅ Complete release automation with version tagging ✅ Web-based installation support Build System: - `build-release.yml` - Automated releases on git tags - `build-dev.yml` - Development build testing - `build.sh` / `build.bat` - Local build scripts - ESP32 Web Tools manifests for both boards - Comprehensive build information generation Installation Options: - 🌐 Web-based: ESP32 Web Tools via weighmybru.com - 💻 Developer: PlatformIO for advanced users - 📦 Manual: Direct binary flashing Documentation: - Added ESP32_WEB_TOOLS.md with complete integration guide - Updated README.md with web installation instructions - Build scripts with help and examples Ready for beginner-friendly web installation! 🎉
1 parent d06d11a commit 3e66e8f

File tree

6 files changed

+1139
-0
lines changed

6 files changed

+1139
-0
lines changed

.github/workflows/build-dev.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build Development
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop, 'feature/*' ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
9+
jobs:
10+
test-build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
environment: [esp32s3-supermini, esp32s3-xiao]
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install PlatformIO
27+
run: |
28+
pip install platformio
29+
pio upgrade --dev
30+
pio pkg update
31+
32+
- name: Extract build info
33+
id: build_info
34+
run: |
35+
BUILD_NUMBER=$GITHUB_RUN_NUMBER
36+
COMMIT_HASH=$(git rev-parse --short HEAD)
37+
BUILD_DATE=$(date -u +"%b %d %Y")
38+
BUILD_TIME=$(date -u +"%H:%M:%S")
39+
40+
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_OUTPUT
41+
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_OUTPUT
42+
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_OUTPUT
43+
echo "BUILD_TIME=$BUILD_TIME" >> $GITHUB_OUTPUT
44+
45+
echo "Building development version"
46+
echo "Build number: $BUILD_NUMBER"
47+
echo "Commit: $COMMIT_HASH"
48+
49+
- name: Build firmware
50+
run: |
51+
# Set build flags for development builds
52+
export PLATFORMIO_BUILD_FLAGS="\
53+
-DWEIGHMYBRU_BUILD_NUMBER=${{ steps.build_info.outputs.BUILD_NUMBER }} \
54+
-DWEIGHMYBRU_COMMIT_HASH=\\\"${{ steps.build_info.outputs.COMMIT_HASH }}\\\" \
55+
-DWEIGHMYBRU_BUILD_DATE=\\\"${{ steps.build_info.outputs.BUILD_DATE }}\\\" \
56+
-DWEIGHMYBRU_BUILD_TIME=\\\"${{ steps.build_info.outputs.BUILD_TIME }}\\\""
57+
58+
echo "Building ${{ matrix.environment }} with flags: $PLATFORMIO_BUILD_FLAGS"
59+
60+
# Test build only
61+
pio run -e ${{ matrix.environment }}
62+
63+
# Check binary size
64+
ls -la .pio/build/${{ matrix.environment }}/firmware.bin
65+
66+
- name: Build check summary
67+
run: |
68+
echo "✅ ${{ matrix.environment }} build successful"
69+
70+
# Get firmware size
71+
FIRMWARE_SIZE=$(stat -c%s ".pio/build/${{ matrix.environment }}/firmware.bin")
72+
FIRMWARE_SIZE_KB=$((FIRMWARE_SIZE / 1024))
73+
74+
echo "📦 Firmware size: ${FIRMWARE_SIZE_KB}KB"
75+
76+
# Check if size is reasonable (under 3MB for ESP32-S3)
77+
MAX_SIZE_KB=3072 # 3MB
78+
if [ $FIRMWARE_SIZE_KB -gt $MAX_SIZE_KB ]; then
79+
echo "⚠️ Warning: Firmware size (${FIRMWARE_SIZE_KB}KB) exceeds recommended maximum (${MAX_SIZE_KB}KB)"
80+
else
81+
echo "✅ Firmware size within acceptable limits"
82+
fi
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
name: Build Release Binaries
2+
3+
on:
4+
push:
5+
tags: ['v*'] # Trigger on version tags like v2.1.0
6+
workflow_dispatch: # Manual trigger for testing
7+
inputs:
8+
version_override:
9+
description: 'Override version (e.g., 2.1.0-beta)'
10+
required: false
11+
type: string
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
environment: [esp32s3-supermini, esp32s3-xiao]
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.x'
29+
30+
- name: Install PlatformIO
31+
run: |
32+
pip install platformio
33+
pio upgrade --dev
34+
pio pkg update
35+
36+
- name: Extract version information
37+
id: version
38+
run: |
39+
if [[ $GITHUB_REF == refs/tags/* ]]; then
40+
# Extract version from git tag (remove 'v' prefix)
41+
VERSION=${GITHUB_REF#refs/tags/v}
42+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
43+
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
44+
elif [[ -n "${{ github.event.inputs.version_override }}" ]]; then
45+
# Use manual override
46+
VERSION="${{ github.event.inputs.version_override }}"
47+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
48+
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT
49+
else
50+
# Development build
51+
VERSION="dev-$(date +%Y%m%d)"
52+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
53+
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT
54+
fi
55+
56+
# Extract build info
57+
BUILD_NUMBER=$GITHUB_RUN_NUMBER
58+
COMMIT_HASH=$(git rev-parse --short HEAD)
59+
BUILD_DATE=$(date -u +"%b %d %Y")
60+
BUILD_TIME=$(date -u +"%H:%M:%S")
61+
62+
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_OUTPUT
63+
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_OUTPUT
64+
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_OUTPUT
65+
echo "BUILD_TIME=$BUILD_TIME" >> $GITHUB_OUTPUT
66+
67+
echo "Building version: $VERSION"
68+
echo "Build number: $BUILD_NUMBER"
69+
echo "Commit: $COMMIT_HASH"
70+
71+
- name: Build firmware
72+
run: |
73+
# Set build flags with version info
74+
export PLATFORMIO_BUILD_FLAGS="\
75+
-DWEIGHMYBRU_BUILD_NUMBER=${{ steps.version.outputs.BUILD_NUMBER }} \
76+
-DWEIGHMYBRU_COMMIT_HASH=\\\"${{ steps.version.outputs.COMMIT_HASH }}\\\" \
77+
-DWEIGHMYBRU_BUILD_DATE=\\\"${{ steps.version.outputs.BUILD_DATE }}\\\" \
78+
-DWEIGHMYBRU_BUILD_TIME=\\\"${{ steps.version.outputs.BUILD_TIME }}\\\""
79+
80+
echo "Building ${{ matrix.environment }} with flags: $PLATFORMIO_BUILD_FLAGS"
81+
82+
# Build firmware
83+
pio run -e ${{ matrix.environment }}
84+
85+
# Build filesystem
86+
pio run -e ${{ matrix.environment }} -t buildfs
87+
88+
- name: Prepare release files
89+
run: |
90+
mkdir -p release
91+
92+
# Determine board suffix for file naming
93+
if [[ "${{ matrix.environment }}" == "esp32s3-supermini" ]]; then
94+
BOARD_SUFFIX="supermini"
95+
else
96+
BOARD_SUFFIX="xiao"
97+
fi
98+
99+
# Copy and rename binaries with version
100+
cp .pio/build/${{ matrix.environment }}/firmware.bin \
101+
release/weighmybru-${BOARD_SUFFIX}-v${{ steps.version.outputs.VERSION }}.bin
102+
103+
# Check if LittleFS was built
104+
if [[ -f .pio/build/${{ matrix.environment }}/littlefs.bin ]]; then
105+
cp .pio/build/${{ matrix.environment }}/littlefs.bin \
106+
release/weighmybru-${BOARD_SUFFIX}-v${{ steps.version.outputs.VERSION }}-littlefs.bin
107+
fi
108+
109+
# Copy bootloader and partitions for complete flashing
110+
if [[ -f .pio/build/${{ matrix.environment }}/bootloader.bin ]]; then
111+
cp .pio/build/${{ matrix.environment }}/bootloader.bin \
112+
release/weighmybru-${BOARD_SUFFIX}-v${{ steps.version.outputs.VERSION }}-bootloader.bin
113+
fi
114+
115+
if [[ -f .pio/build/${{ matrix.environment }}/partitions.bin ]]; then
116+
cp .pio/build/${{ matrix.environment }}/partitions.bin \
117+
release/weighmybru-${BOARD_SUFFIX}-v${{ steps.version.outputs.VERSION }}-partitions.bin
118+
fi
119+
120+
echo "BOARD_SUFFIX=$BOARD_SUFFIX" >> $GITHUB_ENV
121+
122+
- name: Generate ESP32 Web Tools manifest
123+
run: |
124+
BOARD_SUFFIX=${{ env.BOARD_SUFFIX }}
125+
VERSION=${{ steps.version.outputs.VERSION }}
126+
127+
# Determine board-specific settings
128+
if [[ "$BOARD_SUFFIX" == "supermini" ]]; then
129+
BOARD_NAME="WeighMyBru² - ESP32-S3 Supermini"
130+
CHIP_FAMILY="ESP32-S3"
131+
else
132+
BOARD_NAME="WeighMyBru² - XIAO ESP32S3"
133+
CHIP_FAMILY="ESP32-S3"
134+
fi
135+
136+
# Create ESP32 Web Tools manifest
137+
cat > release/manifest-${BOARD_SUFFIX}.json << EOF
138+
{
139+
"name": "$BOARD_NAME",
140+
"version": "$VERSION",
141+
"home_assistant_domain": "weighmybru",
142+
"new_install_prompt_erase": true,
143+
"funding_url": "https://github.com/031devstudios/weighmybru2",
144+
"builds": [
145+
{
146+
"chipFamily": "$CHIP_FAMILY",
147+
"parts": [
148+
{
149+
"path": "weighmybru-${BOARD_SUFFIX}-v${VERSION}-bootloader.bin",
150+
"offset": 0
151+
},
152+
{
153+
"path": "weighmybru-${BOARD_SUFFIX}-v${VERSION}-partitions.bin",
154+
"offset": 32768
155+
},
156+
{
157+
"path": "weighmybru-${BOARD_SUFFIX}-v${VERSION}.bin",
158+
"offset": 65536
159+
},
160+
{
161+
"path": "weighmybru-${BOARD_SUFFIX}-v${VERSION}-littlefs.bin",
162+
"offset": 2686976
163+
}
164+
]
165+
}
166+
]
167+
}
168+
EOF
169+
170+
echo "Generated manifest for $BOARD_NAME v$VERSION"
171+
172+
- name: Create build info file
173+
run: |
174+
cat > release/build-info-${{ env.BOARD_SUFFIX }}.json << EOF
175+
{
176+
"version": "${{ steps.version.outputs.VERSION }}",
177+
"board": "${{ matrix.environment }}",
178+
"build_number": ${{ steps.version.outputs.BUILD_NUMBER }},
179+
"commit_hash": "${{ steps.version.outputs.COMMIT_HASH }}",
180+
"build_date": "${{ steps.version.outputs.BUILD_DATE }}",
181+
"build_time": "${{ steps.version.outputs.BUILD_TIME }}",
182+
"is_release": ${{ steps.version.outputs.IS_RELEASE }},
183+
"github_run_id": "${{ github.run_id }}",
184+
"github_sha": "${{ github.sha }}"
185+
}
186+
EOF
187+
188+
- name: Upload release artifacts
189+
uses: actions/upload-artifact@v3
190+
with:
191+
name: weighmybru-${{ env.BOARD_SUFFIX }}-v${{ steps.version.outputs.VERSION }}
192+
path: release/
193+
retention-days: 90
194+
195+
create-release:
196+
needs: build
197+
runs-on: ubuntu-latest
198+
if: startsWith(github.ref, 'refs/tags/')
199+
200+
steps:
201+
- name: Download all artifacts
202+
uses: actions/download-artifact@v3
203+
204+
- name: Extract version from tag
205+
id: version
206+
run: |
207+
VERSION=${GITHUB_REF#refs/tags/v}
208+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
209+
210+
- name: Organize release files
211+
run: |
212+
mkdir -p release-final
213+
214+
# Combine all artifacts into one release folder
215+
find . -name "*.bin" -o -name "*.json" | while read file; do
216+
cp "$file" release-final/
217+
done
218+
219+
ls -la release-final/
220+
221+
- name: Create GitHub Release
222+
uses: softprops/action-gh-release@v1
223+
with:
224+
tag_name: v${{ steps.version.outputs.VERSION }}
225+
name: WeighMyBru² v${{ steps.version.outputs.VERSION }}
226+
files: release-final/*
227+
body: |
228+
## WeighMyBru² v${{ steps.version.outputs.VERSION }}
229+
230+
### 📦 Release Binaries
231+
232+
**ESP32-S3 Supermini:**
233+
- `weighmybru-supermini-v${{ steps.version.outputs.VERSION }}.bin` - Main firmware
234+
- `weighmybru-supermini-v${{ steps.version.outputs.VERSION }}-littlefs.bin` - Web interface files
235+
- `manifest-supermini.json` - ESP32 Web Tools manifest
236+
237+
**XIAO ESP32S3:**
238+
- `weighmybru-xiao-v${{ steps.version.outputs.VERSION }}.bin` - Main firmware
239+
- `weighmybru-xiao-v${{ steps.version.outputs.VERSION }}-littlefs.bin` - Web interface files
240+
- `manifest-xiao.json` - ESP32 Web Tools manifest
241+
242+
### 🚀 Installation Options
243+
244+
1. **Web-based (Recommended):** Use ESP32 Web Tools on [weighmybru.com](https://weighmybru.com)
245+
2. **Manual:** Download binaries and flash with esptool or PlatformIO
246+
247+
### 📋 Requirements
248+
- ESP32-S3 Supermini or XIAO ESP32S3 board
249+
- Load cell and HX711 amplifier
250+
- See [README.md](https://github.com/031devstudios/weighmybru2/blob/master/README.md) for wiring
251+
252+
### 🔧 Build Information
253+
- Build: #${{ github.run_number }}
254+
- Commit: ${{ github.sha }}
255+
- Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
256+
draft: false
257+
prerelease: false
258+
env:
259+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)