Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
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: "8.3.1"
- 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: "8.3.1"
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
82965f623This file is pinned to the selected release. Download the original to open it in your design tool.