@@ -46,99 +46,69 @@ jobs:
4646 run : |
4747 python -m pip install --upgrade esptool
4848 mkdir -p "$SITE_DIR"
49- # merge a single flashable image using the exact args from the build dir
50- python -m esptool --chip esp32p4 merge_bin \
51- -o "$SITE_DIR/firmware-merged.bin" \
52- "@flash_args"
49+ python -m esptool --chip esp32p4 merge_bin -o "$SITE_DIR/firmware-merged.bin" "@flash_args"
5350
54- - name : Create GitHub Release (build tag) & upload merged bin
55- if : ${{ github.event_name != 'pull_request' }}
51+ # OPTIONAL: publish each build’s bin as a Release asset (so the page can list last 5)
52+ - name : Create Release & upload merged bin (main branch only)
53+ if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
5654 env :
57- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5856 run : |
59- set -e
57+ set -euo pipefail
6058 TAG="build-${{ github.run_number }}"
6159 NAME="M5Tab5 build ${{ github.run_number }}"
6260 BIN="platforms/tab5/site/firmware-merged.bin"
63- LABEL="m5tab5_userdemo-${{ github.run_number }}-${{ github.sha::0:7 }}.bin"
61+ SHORT_SHA="${GITHUB_SHA::7}"
62+ LABEL="m5tab5_userdemo-${{ github.run_number }}-${SHORT_SHA}.bin"
6463
65- # Create release (idempotent if it exists) and upload asset
66- gh release create "$TAG" -t "$NAME" -n "Automated build from ${{ github.sha }}" || true
64+ gh release create "$TAG" -t "$NAME" -n "Automated build from $GITHUB_SHA" || true
6765 gh release upload "$TAG" "$BIN#${LABEL}" --clobber
6866
6967 - name : Prune old build releases (keep last 5)
70- if : ${{ github.event_name != 'pull_request' }}
68+ if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
7169 env :
72- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
70+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7371 run : |
74- set -e
75- # List build-* releases sorted by creation date desc, skip first 5, delete the rest
76- mapfile -t OLD < <(gh release list --limit 100 --json tagName,createdAt --jq '.[] | select(.tagName|startswith("build-")) | .tagName' | tail -n +6)
77- for tag in "${OLD[@]}"; do
78- gh release delete "$tag" -y
79- done
80-
81- - name : Create manifest.json
82- shell : bash
83- working-directory : platforms/tab5/site
84- run : |
85- cat > manifest.json << 'JSON'
86- {
87- "name": "M5Tab5 User Demo",
88- "version": "${{ github.run_number }}",
89- "builds": [{
90- "chipFamily": "ESP32",
91- "parts": [{ "path": "firmware-merged.bin", "offset": 0 }]
92- }]
93- }
94- JSON
95-
96- - name : Create web flasher page(s)
72+ set -euo pipefail
73+ mapfile -t TAGS < <(gh release list --limit 100 --json tagName,createdAt \
74+ --jq '.[] | select(.tagName|startswith("build-")) | .tagName')
75+ # sorted newest->oldest by default; drop first 5
76+ if [ "${#TAGS[@]}" -gt 5 ]; then
77+ for tag in "${TAGS[@]:5}"; do gh release delete "$tag" -y; done
78+ fi
79+
80+ - name : Write site files
9781 shell : bash
9882 working-directory : platforms/tab5/site
9983 run : |
100- cat > index.html << 'HTML'
101- <!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
102- <title>M5Tab5 Web Flash</title>
103- <script type="module"
104- src="https://unpkg.com/esp-web-tools@10/dist/web/install-button.js?module"></script>
105- <h1>M5Tab5 – Web Flash</h1>
106- <esp-web-install-button manifest="manifest.json"></esp-web-install-button>
107- <p>If the installer doesn’t recognize your device, download
108- <a href="firmware-merged.bin" download>firmware-merged.bin</a> and flash with esptool.</p>
109- HTML
110- # Provide flash.html as an alias so /flash.html works too
84+ # Drop in the enhanced index.html from your repo (already added).
85+ # Provide alias for /flash.html and disable Jekyll.
11186 cp index.html flash.html
112- # Avoid Jekyll processing edge-cases
11387 : > .nojekyll
11488
11589 - name : List site files (debug)
116- run : |
117- find platforms/tab5/site -maxdepth 1 -type f -printf "%f\n"
90+ run : find platforms/tab5/site -maxdepth 1 -type f -printf "%f\n"
11891
11992 - name : Upload Pages artifact
12093 uses : actions/upload-pages-artifact@v3
12194 with :
12295 path : platforms/tab5/site
123-
96+
12497 publish :
12598 name : Deploy Web Flash
12699 runs-on : ubuntu-latest
127100 needs : build
101+ if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
128102 permissions :
129103 contents : read
130- pages : write # required by deploy-pages
131- id-token : write # required by deploy-pages
104+ pages : write
105+ id-token : write
132106 environment :
133107 name : github-pages
134108 url : ${{ steps.deployment.outputs.page_url }}
135-
136109 steps :
137- # (optional but recommended) Configure Pages
138- - name : Configure GitHub Pages
110+ - name : Configure Pages
139111 uses : actions/configure-pages@v5
140-
141112 - name : Deploy to GitHub Pages
142113 id : deployment
143114 uses : actions/deploy-pages@v4
144-
0 commit comments