mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-05 20:34:27 +01:00
split-beta, emulator-beta, public-release and installer-pages: the download of the pinned run's github-pages artifact may fail (continue-on-error); the next step (tools/fetch_live_site.py restore) leaves build/released/artifact.tar as the downloaded artifact or, when it expired or is older than the live site, the live site fetched and checked. The steps after it are unchanged. Every deploy (those four, emulator, private-preview, usb-input-release) now writes site-manifest.json (every file, size, SHA-256) and keeps its Pages artifact 90 days instead of 1. Pushing this runs "Publish installer pages" (its workflow file changed): it republishes the live site as it is, plus site-manifest.json. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
153 lines
7.5 KiB
YAML
153 lines
7.5 KiB
YAML
name: Publish verified USB input beta
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths: [web/USB_INPUT_RELEASE.json]
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
pages: write
|
|
id-token: write
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: true
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.13'
|
|
- name: Candidate pin
|
|
id: pin
|
|
run: |
|
|
python3 - <<'PY'
|
|
import json,os,re
|
|
from pathlib import Path
|
|
m=json.loads(Path('web/USB_INPUT_RELEASE.json').read_text())
|
|
assert re.fullmatch('[0-9a-f]{40}',m['source'])
|
|
assert Path('web/PREVIEW').read_text().strip()==m['source']
|
|
with open(os.environ['GITHUB_OUTPUT'],'a') as f:f.write('source='+m['source']+'\n')
|
|
PY
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ steps.pin.outputs.source }}
|
|
path: build/candidate
|
|
persist-credentials: false
|
|
- name: Frozen published site
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: github-pages
|
|
run-id: 41745149049
|
|
github-token: ${{ github.token }}
|
|
path: build/released
|
|
- name: JieLi toolchain cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.jieli
|
|
~/fw-AC79_AIoT_SDK/cpu/wl82/tools
|
|
key: jieli-ac79-v1.2.1
|
|
- name: Toolchain and SDK
|
|
run: |
|
|
retry() { for d in 0 5 15 30; do sleep $d; "$@" && return 0; done; return 1; }
|
|
T=$HOME/fw-AC79_AIoT_SDK/cpu/wl82/tools
|
|
[ -e "$HOME/.jieli/toolchain" ] || retry sh tools/get_toolchain.sh "$HOME/.jieli"
|
|
if [ ! -s "$T/uboot.boot" ] || [ ! -s "$T/cfg_tool.bin" ] || [ ! -s "$T/cfg/eq_cfg_hw.bin" ]; then
|
|
retry git clone --filter=blob:none --no-checkout https://gitee.com/Jieli-Tech/fw-AC79_AIoT_SDK.git "$HOME/fw-AC79_AIoT_SDK"
|
|
cd "$HOME/fw-AC79_AIoT_SDK"
|
|
git sparse-checkout set --no-cone /cpu/wl82/tools/uboot.boot /cpu/wl82/tools/cfg_tool.bin /cpu/wl82/tools/cfg/eq_cfg_hw.bin
|
|
retry git checkout d179b4484759423312073f5fbb232501aa491047
|
|
fi
|
|
test -s "$T/uboot.boot" && test -s "$T/cfg_tool.bin" && test -s "$T/cfg/eq_cfg_hw.bin"
|
|
- name: USB input regressions and target build
|
|
env:
|
|
AC79_SDK: /home/runner/fw-AC79_AIoT_SDK
|
|
JIELI_TOOLCHAIN: /home/runner/.jieli/toolchain
|
|
run: |
|
|
pip install Pillow==12.3.0 numpy==2.3.5 fonttools==4.61.1
|
|
cd build/candidate
|
|
python3 tests/uac_input_irq_test.py
|
|
for CDC in 0 1; do
|
|
cc -O2 -w -DHALF_FRAMES=128 -DT_CDC="$CDC" tests/uac_test.c -lm -o "/tmp/uac-$CDC"
|
|
"/tmp/uac-$CDC"
|
|
done
|
|
python3 tools/build.py
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: usb-input-candidate
|
|
path: |
|
|
build/candidate/build/felucca.fwsc
|
|
build/candidate/build/bt.bin
|
|
build/candidate/build/felucca.bin
|
|
- name: Exact package and beta only
|
|
run: |
|
|
mkdir -p build/pages
|
|
tar -xf build/released/artifact.tar -C build/pages
|
|
node --input-type=module - <<'JS'
|
|
import fs from 'node:fs';import {Package,crc16} from './web/fm1pkg.js';
|
|
const fw='build/pages/preview/firmware/';
|
|
const oldv=JSON.parse(fs.readFileSync(fw+'versions.json'))[0];
|
|
const old=new Package(fs.readFileSync(fw+oldv.file));
|
|
const p=new Package(fs.readFileSync('build/candidate/build/felucca.fwsc'));
|
|
if(p.product!==old.product||p.flashSize!==old.flashSize||p.app.size!==old.app.size||p.sfcEnd>p.flashSize)throw Error('Unexpected package layout');
|
|
if(crc16(p.dec.subarray(p.appOff,p.appOff+p.app.size))!==p.app.dcrc)throw Error('Bad application CRC');
|
|
for(const type of [100]){
|
|
const a=p.entries.find(e=>e.type===type),b=old.entries.find(e=>e.type===type);
|
|
if(!a||!b||a.size!==b.size||!Buffer.from(p.raw.subarray(a.dataOff+p.skew,a.dataOff+p.skew+a.size)).equals(Buffer.from(old.raw.subarray(b.dataOff+old.skew,b.dataOff+old.skew+b.size))))throw Error('Update loader changed');
|
|
}
|
|
const bt=p.entries.find(e=>e.type===200);
|
|
if(!bt||!Buffer.from(p.raw.subarray(bt.dataOff+p.skew,bt.dataOff+p.skew+bt.size)).equals(fs.readFileSync('build/candidate/build/bt.bin')))throw Error('Packaged segment differs from linked build');
|
|
console.log('PASS package CRC, layout, unchanged update loader, exact linked segment');
|
|
JS
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
import hashlib,json,re,shutil,sys,struct,zlib
|
|
sys.path.insert(0,'web');import make_site
|
|
m=json.loads(Path('web/USB_INPUT_RELEASE.json').read_text())
|
|
seg=Path('build/candidate/build/bt.bin').read_bytes()
|
|
magic,length,crc=struct.unpack_from('<III',seg)
|
|
assert magic==0x3154424A and length==len(seg)-32 and crc==zlib.crc32(seg[32:]),'invalid segment CRC'
|
|
assert struct.pack('<III',0x544E5742,length,crc) in Path('build/candidate/build/felucca.bin').read_bytes(),'app/segment pairing mismatch'
|
|
pages=Path('build/pages');fw=pages/'preview/firmware'
|
|
def digest(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
def protected():
|
|
return {p.relative_to(pages).as_posix():digest(p) for p in pages.rglob('*') if p.is_file() and p.relative_to(pages).parts[0]!='preview'}
|
|
before=protected()
|
|
prior=json.loads((fw/'versions.json').read_text())
|
|
old={v['file']:digest(fw/v['file']) for v in prior}
|
|
v=re.search(r'^#define FELUCCA_VERSION "([^"]+)"',Path('build/candidate/firmware/src/felucca.c').read_text(),re.M).group(1)
|
|
assert m['version']==v+'-'+m['source'][:7]+'-preview'
|
|
make_site.main('build/candidate/build/felucca.fwsc',m['version'],'build/new-preview',str(fw))
|
|
shutil.rmtree(pages/'preview');shutil.copytree('build/new-preview',pages/'preview')
|
|
fw=pages/'preview/firmware';versions=json.loads((fw/'versions.json').read_text())
|
|
assert len(versions)==3 and versions[0]['version']==m['version']
|
|
for name,h in old.items():assert digest(fw/name)==h,'previous beta package changed'
|
|
(fw/'SOURCE_COMMIT').write_text(m['source']+'\n')
|
|
(fw/'SHA256SUMS').write_text(''.join(digest(p)+' '+p.name+'\n' for p in sorted(fw.glob('felucca-*.fwsc'))))
|
|
assert before==protected(),'a public or emulator file changed'
|
|
print('PASS previous beta bytes preserved; every file outside beta preserved')
|
|
print('Published versions:',[x['version'] for x in versions])
|
|
print('New package SHA256:',digest(fw/versions[0]['file']))
|
|
PY
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: usb-input-fix2
|
|
path: build/candidate/build/felucca.fwsc
|
|
- name: Site manifest (every file with its SHA-256, for the next publish to recover the site exactly)
|
|
run: python3 tools/fetch_live_site.py manifest build/pages
|
|
- uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: build/pages
|
|
retention-days: 90 # (the default is 1 day: the next publish starts from this artifact)
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-24.04
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- id: deployment
|
|
uses: actions/deploy-pages@v4
|