forked from m5stack/M5Tab5-UserDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (118 loc) · 4.24 KB
/
idf-build-and-webflash.yml
File metadata and controls
135 lines (118 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: IDF Build + Web Flash Deploy
on:
push:
pull_request:
permissions:
contents: read
actions: read
pages: write
id-token: write
jobs:
build:
name: Build (ESP-IDF 5.4.2)
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
pages: write
id-token: write
steps:
- name: Checkout (no LFS)
uses: actions/checkout@v4
with:
lfs: false
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Fetch external repos
run: python ./fetch_repos.py
- name: Build with ESP-IDF 5.4.2 (esp32p4)
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.4.2
target: esp32p4
path: platforms/tab5
command: |
set -euo pipefail
if grep -R "espressif/settings_core" -n .; then
echo "Do not reference espressif/settings_core"
exit 1
fi
rm -rf managed_components
idf.py reconfigure
idf.py build
- name: Merge firmware for ESP Web Tools
shell: bash
working-directory: platforms/tab5/build
env:
SITE_DIR: ${{ github.workspace }}/platforms/tab5/site
run: |
python -m pip install --upgrade esptool
mkdir -p "$SITE_DIR"
python -m esptool --chip esp32p4 merge_bin -o "$SITE_DIR/firmware-merged.bin" "@flash_args"
# OPTIONAL: publish each build’s bin as a Release asset (so the page can list last 5)
- name: Create Release & upload merged bin (main branch only)
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # gh prefers GH_TOKEN; GITHUB_TOKEN also works
run: |
set -euo pipefail
TAG="build-${{ github.run_number }}"
NAME="M5Tab5 build ${{ github.run_number }}"
BIN="platforms/tab5/site/firmware-merged.bin"
SHORT_SHA="${GITHUB_SHA::7}"
LABEL="m5tab5_userdemo-${{ github.run_number }}-${SHORT_SHA}.bin"
# create (idempotent)
gh release create "$TAG" -t "$NAME" -n "Automated build from $GITHUB_SHA" || true
# verify release exists before uploading
if ! gh release view "$TAG" >/dev/null 2>&1; then
echo "::error::Release $TAG was not created (check token permissions: contents: write)."
exit 1
fi
gh release upload "$TAG" "$BIN#${LABEL}" --clobber
- name: Prune old build releases (keep last 5)
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
mapfile -t TAGS < <(gh release list --limit 100 --json tagName,createdAt \
--jq '.[] | select(.tagName|startswith("build-")) | .tagName')
# sorted newest->oldest by default; drop first 5
if [ "${#TAGS[@]}" -gt 5 ]; then
for tag in "${TAGS[@]:5}"; do gh release delete "$tag" -y; done
fi
- name: Write site files
shell: bash
working-directory: platforms/tab5/site
run: |
# Drop in the enhanced index.html from your repo (already added).
# Provide alias for /flash.html and disable Jekyll.
cp index.html flash.html
: > .nojekyll
- name: List site files (debug)
run: find platforms/tab5/site -maxdepth 1 -type f -printf "%f\n"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: platforms/tab5/site
publish:
name: Deploy Web Flash
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4