ci: vendor micro:bit payload + build workflow (ROOT=/scratch/, upload artifact)

This commit is contained in:
DHEnry committed 2026-10-19 01:14:34 +08:00
1 parent 9ba20f9ef3
commit 78ff25fe7c
3 files changed
+26436

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
name: Build
# 触发:组织仓库的两个主分支 push + 手动(fork/PR 运行只做质检不上传,令牌只读)
on:
push:
branches: [develop, codex/editor-backend-integration]
workflow_dispatch:
env:
GH_PROXY: https://v4.gh-proxy.org
jobs:
build:
name: Build
runs-on: ubuntu-latest
# npm ci(依赖树庞大)+ webpack 4 全量构建,runner 较慢,放宽超时
timeout-minutes: 60
steps:
- uses: https://gitea.com/actions/checkout@v4
# 1. 手动安装 Node(runner 没有 hostedtoolcache,与 Backend/Frontend CI 同款)
- name: Setup Node.js manually
run: |
NODE_VERSION="22.23.3"
NODE_HASH="35947643734"
echo "Downloading Node.js v${NODE_VERSION} via proxy..."
curl -fL "${GH_PROXY}/https://github.com/actions/node-versions/releases/download/${NODE_VERSION}-${NODE_HASH}/node-${NODE_VERSION}-linux-x64.tar.gz" -o node.tar.gz
sudo mkdir -p /opt/hostedtoolcache/node/${NODE_VERSION}/x64
sudo tar -zxvf node.tar.gz -C /opt/hostedtoolcache/node/${NODE_VERSION}/x64 --strip-components=1
echo "/opt/hostedtoolcache/node/${NODE_VERSION}/x64/bin" >> "$GITHUB_PATH"
/opt/hostedtoolcache/node/${NODE_VERSION}/x64/bin/node -v
/opt/hostedtoolcache/node/${NODE_VERSION}/x64/bin/npm -v
# 2. npm 镜像
- name: Configure npm mirror
run: npm config set registry https://registry.npmmirror.com
- name: Install dependencies
run: npm ci
# 3. micro:bit 包载入(生成物已提交入库则跳过;回退到脚本在线下载走 cross-fetch)
- name: Get micro:bit payload
run: |
if [ -f src/generated/microbit-hex-url.cjs ] && [ -f static/microbit/scratch-microbit-1.2.0.hex ]; then
echo "生成物已入库,跳过下载"
else
npm run prepublish
fi
# 4. 编辑器单元测试(Lint 跳过:menu-bar 存在既有的 24 项 lint 问题)
- name: Unit tests (sccn)
run: npx jest --runInBand test/unit/sccn test/unit/reducers/project-state-reducer.test.js
# 5. 生产构建:Webpack 4 需要 legacy OpenSSL;ROOT 决定部署子路径
- name: Build editor (ROOT=/scratch/)
env:
NODE_ENV: production
ROOT: /scratch/
NODE_OPTIONS: --openssl-legacy-provider
run: npm run build
# 6. 打包 build/(顶层无子目录,解压后直接是一组站点文件:editor.html、getter.js 等)
- name: Package build
run: |
set -eu
test -f build/editor.html
TARBALL="scratch-gui-build-${GITHUB_SHA::7}.tar.gz"
tar -czf "$TARBALL" -C build .
echo "--- 包内清单(前 20 行)---"
tar -tzf "$TARBALL" | head -20
echo "--- 大小 ---"
ls -lh "$TARBALL"
# 7. 上传为 Gitea Actions Artifact(push / 手动触发才上传)
- name: Upload build artifact
if: github.event_name != 'pull_request'
uses: https://gitea.com/actions/upload-artifact@v4
with:
name: scratch-gui-build-${{ github.sha }}
path: scratch-gui-build-*.tar.gz
retention-days: 30
+5
View File
@@ -0,0 +1,5 @@
// This file is generated by scripts/prepublish.mjs
// Do not edit this file directly
// This file relies on a loader to turn this `require` into a URL
module.exports = require('../static/microbit/scratch-microbit-1.2.0.hex');
File diff suppressed because it is too large. Load diff