-
-
Notifications
You must be signed in to change notification settings - Fork 213
248 lines (241 loc) · 8.05 KB
/
Copy pathbundle.yml
File metadata and controls
248 lines (241 loc) · 8.05 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: Bundle Stack-chan Firmware
on:
push:
branches:
- develop
- main
paths:
- "firmware/**"
- "web/**"
- ".github/scripts/**"
- ".github/actions/setup/action.yml"
- ".github/workflows/bundle.yml"
- ".github/workflows/cloudflare-preview.yml"
pull_request:
branches:
- develop
- main
paths:
- "firmware/**"
- "web/**"
- ".github/scripts/**"
- ".github/actions/setup/action.yml"
- ".github/workflows/bundle.yml"
- ".github/workflows/cloudflare-preview.yml"
permissions:
contents: read
concurrency:
group: bundle-${{ github.ref }}
cancel-in-progress: true
jobs:
firmware:
name: Release build (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: m5stack
command: npm run build:release:m5stack
bundle: true
- target: m5stack_core2
command: npm run build:release:m5stack_core2
bundle: true
- target: m5stack_cores3
command: npm run build:release:m5stack_cores3
bundle: true
- target: m5stackchan_cores3
command: npm run build:release:m5stackchan_cores3
bundle: true
- target: stackchan_rt
command: npm run build:release:stackchan_rt
bundle: false
- target: takao_core2_sg90
command: npm run build:release:takao_core2_sg90
bundle: false
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup
uses: ./.github/actions/setup
with:
target-branch: "9.0.0"
- name: Build release firmware
working-directory: ./firmware
run: source "$HOME/.local/share/xs-dev-export.sh" && ${{ matrix.command }}
- name: Upload bundle target
if: matrix.bundle
uses: actions/upload-artifact@v7
with:
name: firmware-bundle-target-${{ matrix.target }}
path: ./firmware/dist/bundle-targets
if-no-files-found: error
web:
name: Bundle web artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup
uses: ./.github/actions/setup
with:
target-branch: "9.0.0"
install-emscripten: "true"
- name: Install web dependencies
working-directory: ./firmware
run: npm --prefix ../web ci
- name: Rebuild editor tools for release verification
working-directory: ./firmware
run: source "$HOME/.local/share/xs-dev-export.sh" && npm run build:editor-tools
- name: Verify release editor tools
working-directory: ./firmware
run: |
npm --prefix ../web run check:editor-artifacts
git diff --exit-code -- ':(top)web/editor/vendor/tools.js' ':(top)web/editor/vendor/tools.wasm'
- name: Build WASM simulator firmware
working-directory: ./firmware
run: source "$HOME/.local/share/xs-dev-export.sh" && npm run build:wasm
- name: Build web application
working-directory: ./firmware
run: npm --prefix ../web run build
- name: Upload web application
uses: actions/upload-artifact@v7
with:
name: web-dist
path: ./web/dist
if-no-files-found: error
build:
needs:
- firmware
- web
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version: 22
- name: Download bundle targets
uses: actions/download-artifact@v8
with:
pattern: firmware-bundle-target-*
path: ./firmware/dist/bundle-targets
merge-multiple: true
- name: Package firmware bundle
working-directory: ./firmware
run: npm run bundle:package
- name: Upload firmware bundle
uses: actions/upload-artifact@v7
with:
name: firmware-bundle
path: ./firmware/host/app/tech.moddable.stackchan
if-no-files-found: error
- name: Download web application
uses: actions/download-artifact@v8
with:
name: web-dist
path: ./web/dist
- name: Checkout Pages baseline
if: github.event_name == 'pull_request'
uses: actions/checkout@v7
with:
ref: gh-pages
path: pages-baseline
persist-credentials: false
- name: Assemble Cloudflare Pages preview
if: github.event_name == 'pull_request'
run: |
set -euo pipefail
test -s ./pages-baseline/web/schematics/index.html
mkdir -p ./pages-preview
cp -R ./web/dist/. ./pages-preview/
rm -rf \
./pages-preview/schematics \
./pages-preview/flash/tech.moddable.stackchan
mkdir -p ./pages-preview/flash/tech.moddable.stackchan
cp -R ./pages-baseline/web/schematics ./pages-preview/schematics
cp -R \
./firmware/host/app/tech.moddable.stackchan/. \
./pages-preview/flash/tech.moddable.stackchan/
mkdir -p ./pages-preview/schemas
cp \
./docs/specs/stackchan-mod.schema.json \
./pages-preview/schemas/stackchan-mod.schema.json
- name: Validate Cloudflare Pages preview
if: github.event_name == 'pull_request'
run: |
node --test .github/scripts/*.test.mjs
node .github/scripts/validate-pages-preview.mjs ./pages-preview
- name: Upload Cloudflare Pages preview
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v7
with:
name: cloudflare-pages-preview
path: ./pages-preview
retention-days: 2
if-no-files-found: error
deploy:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
permissions:
contents: write
steps:
- name: Checkout Pages branch
uses: actions/checkout@v7
with:
ref: gh-pages
- name: Checkout website source
uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
path: website-source
persist-credentials: false
- name: Download firmware bundle
uses: actions/download-artifact@v8
with:
name: firmware-bundle
path: ./firmware-bundle
- name: Download web application
uses: actions/download-artifact@v8
with:
name: web-dist
path: ./web-dist
- name: Update bundle files
run: |
if [ -z "$(find ./firmware-bundle -mindepth 1 -print -quit)" ]; then
echo "Firmware bundle artifact is empty"
exit 1
fi
if [ -z "$(find ./web-dist -mindepth 1 -print -quit)" ]; then
echo "Web application artifact is empty"
exit 1
fi
test -s ./web-dist/simulator/mc.js
test -s ./web-dist/simulator/mc.wasm
rsync -a --delete \
--exclude '/schematics/' \
--exclude '/flash/tech.moddable.stackchan/' \
./web-dist/ ./web/
rm -rf ./web/flash/tech.moddable.stackchan
mkdir -p ./web/flash/tech.moddable.stackchan
cp -R ./firmware-bundle/. ./web/flash/tech.moddable.stackchan/
mkdir -p ./web/schemas
cp ./website-source/docs/specs/stackchan-mod.schema.json ./web/schemas/stackchan-mod.schema.json
- name: Commit bundle update
run: |
git config user.name 'GitHub Action'
git config user.email 'action@github.com'
git add --all ./web
if git diff --cached --quiet; then
echo "No bundle changes to deploy"
exit 0
fi
git commit -m "Deploy website and firmware bundle from ${{ github.sha }}"
git push origin HEAD:gh-pages