Skip to content

Commit 7f03fb3

Browse files
committed
2 parents 47c2fcc + 937aef1 commit 7f03fb3

1 file changed

Lines changed: 193 additions & 0 deletions

File tree

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Build ODMR Firmware from external repository
2+
# This workflow clones and builds the ODMR firmware from TechnicalDocs-openUC2-QBox
3+
# and uploads binaries to youseetoo.github.io for web flasher integration
4+
5+
name: Build ODMR Firmware (External)
6+
7+
on:
8+
workflow_dispatch:
9+
schedule:
10+
# Run weekly on Monday at 2 AM UTC
11+
- cron: '0 2 * * 1'
12+
push:
13+
branches:
14+
- 'main'
15+
paths:
16+
- '.github/workflows/build-odmr-external.yaml'
17+
18+
env:
19+
ODMR_REPO: 'openUC2/TechnicalDocs-openUC2-QBox'
20+
WEB_REPO: 'youseetoo/youseetoo.github.io'
21+
22+
jobs:
23+
# ==============================================================
24+
# BUILD — compile each ODMR environment in matrix
25+
# ==============================================================
26+
build:
27+
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
# ---------- ESP32‑S3 ----------
33+
- env_name: seeed_xiao_esp32s3
34+
chip: esp32s3
35+
flash_size: 4MB
36+
partition_csv: custom_partition_esp32s3.csv
37+
display_name: "ODMR Xiao ESP32S3"
38+
board_id: "odmr-xiao-esp32s3"
39+
# ---------- ESP32‑C3 ----------
40+
- env_name: seeed_xiao_esp32c3
41+
chip: esp32c3
42+
flash_size: 4MB
43+
partition_csv: custom_partition_esp32c3.csv
44+
display_name: "ODMR Xiao ESP32C3"
45+
board_id: "odmr-xiao-esp32c3"
46+
47+
steps:
48+
# ---------------- CHECKOUT ODMR SOURCE ----------------
49+
- name: Checkout ODMR firmware source (+submodules)
50+
uses: actions/checkout@v4
51+
with:
52+
repository: ${{ env.ODMR_REPO }}
53+
fetch-depth: 0
54+
submodules: recursive
55+
token: ${{ secrets.API_TOKEN_GITHUB }}
56+
57+
# ---------------- PYTHON TOOLCHAIN ---------------
58+
- name: Set up Python 3.9
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: '3.9'
62+
63+
- name: Install PlatformIO & helpers
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install platformio esptool
67+
68+
# ---------------- SET PROJECT PATH ----------------
69+
- name: Navigate to PIO project
70+
run: |
71+
PROJECT_DIR="${GITHUB_WORKSPACE}/Production_Files/Software/ODMR_Server"
72+
echo "PROJECT_DIR=$PROJECT_DIR" >> $GITHUB_ENV
73+
echo "==> PIO project at: $PROJECT_DIR"
74+
ls -la "$PROJECT_DIR"
75+
76+
- name: Install PlatformIO libs
77+
run: pio lib install
78+
working-directory: ${{ env.PROJECT_DIR }}
79+
80+
# ---------------- COMPILE APP --------------------
81+
- name: Build firmware – ${{ matrix.env_name }}
82+
run: pio run -v --environment ${{ matrix.env_name }}
83+
working-directory: ${{ env.PROJECT_DIR }}
84+
85+
# ---------------- MERGE BINARIES ------------------
86+
- name: Merge binaries
87+
shell: bash
88+
working-directory: ${{ env.PROJECT_DIR }}
89+
run: |
90+
BUILD_DIR=".pio/build/${{ matrix.env_name }}"
91+
mkdir -p "${GITHUB_WORKSPACE}/build/fw-images"
92+
93+
cd "$BUILD_DIR"
94+
95+
# Determine bootloader address based on chip
96+
if [[ "${{ matrix.chip }}" == "esp32s3" ]]; then
97+
BOOT_ADDR="0x0"
98+
else
99+
BOOT_ADDR="0x1000"
100+
fi
101+
102+
# Find boot_app0.bin
103+
BOOT_APP0=$(find ~/.platformio -name "boot_app0.bin" | head -1)
104+
105+
# Merge all binaries (no filesystem - website embedded as headers)
106+
python -m esptool --chip ${{ matrix.chip }} merge_bin \
107+
-o "${GITHUB_WORKSPACE}/build/fw-images/${{ matrix.board_id }}.bin" \
108+
--flash_mode dio --flash_freq 40m --flash_size ${{ matrix.flash_size }} \
109+
$BOOT_ADDR bootloader.bin \
110+
0x8000 partitions.bin \
111+
0xe000 "$BOOT_APP0" \
112+
0x10000 firmware.bin
113+
114+
echo "==> Merged binary created: ${{ matrix.board_id }}.bin"
115+
116+
# ---------------- CREATE MANIFEST -----------------
117+
- name: Create ESP Web Tools manifest
118+
run: |
119+
# Get version from ODMR repo
120+
cd "${{ env.PROJECT_DIR }}"
121+
ODMR_VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev-$(git rev-parse --short HEAD)")
122+
echo "ODMR Version: $ODMR_VERSION"
123+
124+
# Create manifest for ESP Web Tools
125+
cat > "${GITHUB_WORKSPACE}/build/fw-images/${{ matrix.board_id }}-manifest.json" << EOF
126+
{
127+
"name": "${{ matrix.display_name }}",
128+
"version": "$ODMR_VERSION",
129+
"home_assistant_domain": "ODMR-ESP32",
130+
"funding_url": "https://github.com/${{ env.ODMR_REPO }}",
131+
"builds": [
132+
{
133+
"chipFamily": "ESP32-${{ matrix.chip }}",
134+
"parts": [{ "path": "${{ matrix.board_id }}.bin", "offset": 0 }]
135+
}
136+
]
137+
}
138+
EOF
139+
140+
# ---------------- UPLOAD ARTIFACT ----------------
141+
- name: Publish merged artifact
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: odmr-${{ matrix.board_id }}-bin
145+
path: build/fw-images/
146+
147+
# ==============================================================
148+
# DEPLOY — push to youseetoo.github.io
149+
# ==============================================================
150+
deploy:
151+
needs: build
152+
runs-on: ubuntu-latest
153+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
154+
steps:
155+
# ---------------- GATHER ARTIFACTS ---------------
156+
- name: Download all ODMR firmware artifacts
157+
uses: actions/download-artifact@v4
158+
with:
159+
path: firmware_artifacts
160+
pattern: odmr-*-bin
161+
merge-multiple: true
162+
163+
- name: List downloaded artifacts
164+
run: |
165+
echo "==> Downloaded ODMR firmware:"
166+
ls -la firmware_artifacts/
167+
168+
# ---------------- CHECKOUT WEB REPO --------------
169+
- name: Checkout youseetoo.github.io (target)
170+
uses: actions/checkout@v4
171+
with:
172+
repository: ${{ env.WEB_REPO }}
173+
path: dest
174+
token: ${{ secrets.API_TOKEN_GITHUB }}
175+
176+
# ---------------- COPY & COMMIT ------------------
177+
- name: Copy binaries & commit
178+
shell: bash
179+
run: |
180+
mkdir -p dest/static/firmware_odmr
181+
cp firmware_artifacts/* dest/static/firmware_odmr/
182+
183+
cd dest
184+
git config user.email 'bene.d@gmx.de'
185+
git config user.name 'beniroquai'
186+
187+
if git status --porcelain | grep -q '^??\|^ M'; then
188+
git add static/firmware_odmr
189+
git commit -m "Update ODMR firmware binaries (ESP32-C3 & ESP32-S3) => https://github.com/${{ env.ODMR_REPO }}"
190+
git push
191+
else
192+
echo "No changes to commit"
193+
fi

0 commit comments

Comments
 (0)