|
1 | | -name: Web Flash (Pages) - ESP Web Tools |
| 1 | +name: Web Flash (from IDF Build artifact) |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: [ "v*" ] |
6 | | - release: |
7 | | - types: [published] |
8 | | - workflow_dispatch: |
9 | | - |
10 | | -permissions: |
11 | | - contents: read |
12 | | - pages: write |
13 | | - id-token: write |
14 | | - |
15 | | -concurrency: |
16 | | - group: "pages" |
17 | | - cancel-in-progress: true |
| 4 | + workflow_run: |
| 5 | + workflows: ["IDF Build (ESP32-P4)"] |
| 6 | + types: [completed] |
18 | 7 |
|
19 | 8 | jobs: |
20 | | - build-and-publish: |
| 9 | + publish: |
| 10 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
21 | 11 | runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + actions: read |
| 15 | + pages: write |
| 16 | + id-token: write |
22 | 17 |
|
23 | 18 | steps: |
24 | | - - name: Checkout (with submodules) |
25 | | - uses: actions/checkout@v4 |
| 19 | + - name: Download build artifact from triggering run |
| 20 | + uses: actions/download-artifact@v5 |
26 | 21 | with: |
27 | | - submodules: recursive |
| 22 | + # We named the artifact with the build run_id in the IDF workflow |
| 23 | + name: tab5-build-${{ github.event.workflow_run.id }} |
| 24 | + # v5 supports cross-run downloads when given run-id & token/permissions |
| 25 | + run-id: ${{ github.event.workflow_run.id }} |
| 26 | + path: _dl |
28 | 27 |
|
29 | | - - name: Prepare ccache |
30 | | - run: mkdir -p .ccache |
31 | | - |
32 | | - - name: Restore ccache |
33 | | - uses: actions/cache@v4 |
| 28 | + - name: Set up Python and install esptool |
| 29 | + uses: actions/setup-python@v5 |
34 | 30 | with: |
35 | | - path: .ccache |
36 | | - key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ hashFiles('**/CMakeLists.txt', 'sdkconfig*', '**/*.[ch]', '**/*.cpp') }} |
37 | | - restore-keys: | |
38 | | - ccache-${{ runner.os }}-${{ github.ref_name }}- |
39 | | - ccache-${{ runner.os }}- |
| 31 | + python-version: '3.x' |
| 32 | + - run: python -m pip install --upgrade pip esptool |
40 | 33 |
|
41 | | - - name: Build firmware (ESP-IDF 5.4.x / esp32p4) |
42 | | - uses: espressif/esp-idf-ci-action@v1 |
43 | | - env: |
44 | | - IDF_TARGET: esp32p4 |
45 | | - with: |
46 | | - esp_idf_version: v5.4.2 |
47 | | - target: esp32p4 |
48 | | - path: . |
49 | | - extra_docker_args: "-v ${{ github.workspace }}/.ccache:/root/.ccache -e CCACHE_DIR=/root/.ccache" |
50 | | - |
51 | | - - name: Collect firmware |
52 | | - id: fw |
| 34 | + - name: Merge firmware (ESP-IDF v4+ requires single merged file for Web Tools) |
| 35 | + working-directory: _dl/platforms/tab5/build |
53 | 36 | run: | |
54 | | - mkdir -p site |
55 | | - FWBIN="$(ls build/*.bin | head -n1)" |
56 | | - test -n "$FWBIN" |
57 | | - cp "$FWBIN" site/firmware.bin |
58 | | - if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
59 | | - VER="${GITHUB_REF_NAME}" |
60 | | - else |
61 | | - VER="$(git rev-parse --short HEAD)" |
62 | | - fi |
63 | | - echo "ver=$VER" >> $GITHUB_OUTPUT |
| 37 | + mkdir -p ../../../site |
| 38 | + # Use the exact flash layout created by the build: |
| 39 | + python -m esptool --chip esp32p4 merge_bin \ |
| 40 | + -o ../../../site/firmware-merged.bin \ |
| 41 | + "@flash_args" |
64 | 42 |
|
65 | | - - name: Create manifest.json for ESP Web Tools |
| 43 | + - name: Create ESP Web Tools manifest |
| 44 | + working-directory: _dl/site |
66 | 45 | run: | |
67 | | - cat > site/manifest.json << JSON |
| 46 | + VER="${{ github.event.workflow_run.run_number }}" |
| 47 | + cat > manifest.json << 'JSON' |
68 | 48 | { |
69 | 49 | "name": "M5Tab5 User Demo", |
70 | | - "version": "${{ steps.fw.outputs.ver }}", |
| 50 | + "version": "R${{ github.event.workflow_run.run_number }}", |
71 | 51 | "builds": [{ |
72 | 52 | "chipFamily": "ESP32", |
73 | 53 | "parts": [ |
74 | | - { "path": "firmware.bin", "offset": 0 } |
| 54 | + { "path": "firmware-merged.bin", "offset": 0 } |
75 | 55 | ] |
76 | 56 | }] |
77 | 57 | } |
78 | 58 | JSON |
79 | 59 |
|
80 | | - - name: Create flash.html (install button) |
81 | | - run: | |
82 | | - cat > site/flash.html << 'HTML' |
83 | | - <!doctype html> |
84 | | - <html lang="en"> |
85 | | - <head> |
86 | | - <meta charset="utf-8" /> |
87 | | - <meta name="viewport" content="width=device-width, initial-scale=1" /> |
88 | | - <title>M5Tab5 – Web Flash</title> |
89 | | - <!-- Load ESP Web Tools button --> |
90 | | - <script type="module" src="https://unpkg.com/esp-web-tools@10/dist/web/install-button.js?module"></script> |
91 | | - <style> |
92 | | - body{font-family:system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; |
93 | | - display:grid; place-items:center; min-height:100dvh; margin:0; background:#0b0c10;} |
94 | | - .card{background:#121418; color:#e6e6e6; padding:24px; border-radius:16px; box-shadow:0 10px 30px #0008;} |
95 | | - h1{margin:0 0 8px} |
96 | | - p{opacity:.8; margin:0 0 16px} |
97 | | - esp-web-install-button{--mdc-theme-primary:#38bdf8} |
98 | | - </style> |
99 | | - </head> |
100 | | - <body> |
101 | | - <div class="card"> |
102 | | - <h1>M5Tab5 – Web Flash</h1> |
103 | | - <p>Connect your Tab5 (ESP32-P4), then click Install.</p> |
104 | | - <esp-web-install-button manifest="manifest.json"></esp-web-install-button> |
105 | | - </div> |
106 | | - </body> |
107 | | - </html> |
108 | | - HTML |
109 | | -
|
110 | 60 | - name: Upload Pages artifact |
111 | 61 | uses: actions/upload-pages-artifact@v3 |
112 | 62 | with: |
113 | | - path: site |
| 63 | + path: _dl/site |
114 | 64 |
|
115 | 65 | - name: Deploy to GitHub Pages |
| 66 | + id: deployment |
116 | 67 | uses: actions/deploy-pages@v4 |
0 commit comments