mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-05 20:34:27 +01:00
- web/emu/build_versions.sh (emulator.yml, cached by commit): web/STABLE and web/CLASSIC (less web/WITHDRAWN) each built from its own commit with its own page, worklet and wasm under emu-v/<sha7>/, its flash under its own key (felucca-emu-flash-<sha7>), emu-v/index.json; a commit that does not build is listed as 'no emulator' - web/emu/picker.js: on preview/emu (injected by emulator.yml and split-beta.yml) a Version menu: the beta, the public release, every CLASSIC version; another version opens in a frame over the page, the beta's audio suspended, back with Beta; the choice remembered in the browser; a one-time note that each version keeps its own memory and an older one may not read a newer project. On a version's own page the menu goes to the others Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
178 lines
10 KiB
YAML
178 lines
10 KiB
YAML
name: Publish verified ADD beta
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths: [web/SPLIT_BETA.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
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
python3 - <<'PY'
|
|
import json,os,re,urllib.request
|
|
from pathlib import Path
|
|
m=json.loads(Path('web/SPLIT_BETA.json').read_text())
|
|
assert re.fullmatch('[0-9a-f]{40}',m['source'])
|
|
assert Path('web/PREVIEW').read_text().strip()==m['source']
|
|
req=urllib.request.Request(f'https://api.github.com/repos/{os.environ["GITHUB_REPOSITORY"]}/actions/runs/{m["run_id"]}',headers={'Authorization':'Bearer '+os.environ['GH_TOKEN']})
|
|
run=json.load(urllib.request.urlopen(req))
|
|
assert run['status']=='completed' and run['conclusion']=='success','candidate checks failed'
|
|
assert run['head_sha']==m['source'] and run['head_branch'] in ('codex/beta-bass-continuity','codex/v56-fm','codex/v65-punch','codex/v66-clean'),'candidate provenance mismatch' # (V10.7.56: the V10.7.23-based line)
|
|
with open(os.environ['GITHUB_OUTPUT'],'a') as f:
|
|
f.write('source='+m['source']+'\n')
|
|
f.write('run_id='+str(m['run_id'])+'\n')
|
|
PY
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ steps.pin.outputs.source }}
|
|
path: build/candidate
|
|
persist-credentials: false
|
|
- name: Frozen published site
|
|
id: site
|
|
continue-on-error: true
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: github-pages
|
|
run-id: 44538040255
|
|
github-token: ${{ github.token }}
|
|
path: build/released
|
|
- name: Published site to start from (the artifact; the live site when it expired or is older)
|
|
# The Pages artifact of the pinned run expires; the live site does not. tools/fetch_live_site.py leaves at
|
|
# build/released/artifact.tar the downloaded artifact, or the live site fetched file by file and checked
|
|
# (site-manifest.json, SHA256SUMS, versions.json); it stops the run rather than start from a partial site.
|
|
run: |
|
|
[ "${{ steps.site.outcome }}" = success ] || rm -rf build/released
|
|
python3 tools/fetch_live_site.py restore --artifact build/released/artifact.tar
|
|
- name: Exact tested firmware
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: voice-user-candidate
|
|
run-id: ${{ steps.pin.outputs.run_id }}
|
|
github-token: ${{ github.token }}
|
|
path: build/candidate
|
|
- name: Exact tested beta emulator
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: drum-kits-emulator-candidate
|
|
run-id: ${{ steps.pin.outputs.run_id }}
|
|
github-token: ${{ github.token }}
|
|
path: build/beta-emulator
|
|
- 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/SPLIT_BETA.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'
|
|
policy=Path('web/PUBLIC_CHANNEL.json')
|
|
if policy.exists() and json.loads(policy.read_text()).get('mode')=='stable-only':
|
|
allowed=[v['version'] for v in json.loads(policy.read_text())['versions']]
|
|
assert {make_site.base_of(x) for x in allowed}<={make_site.base_of(v['version']) for v in json.loads((pages/'firmware/versions.json').read_text())},'the stable public references missing' # (V10.8.4: web/CLASSIC's rebuilds carry -sha7) # (V10.7.56: a public release on top of them)
|
|
def digest(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
assert digest(Path('build/candidate/build/felucca.fwsc'))==m['sha256'],'candidate package SHA256 mismatch'
|
|
def protected():
|
|
return {p.relative_to(pages).as_posix():digest(p) for p in pages.rglob('*') if p.is_file() and not p.relative_to(pages).as_posix().startswith(('preview/firmware/','preview/webapp/installer/','preview/webapp/editor/','preview/webapp/vel/','preview/emu/'))}
|
|
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'
|
|
edition_path=Path('web/EDITIONS.json')
|
|
editions=json.loads(edition_path.read_text())
|
|
for entry in prior:
|
|
editions.setdefault(entry['version'],{k:entry[k] for k in ('edition','status') if k in entry})
|
|
editions[m['version']]={'edition':v,'status':'beta'}
|
|
edition_path.write_text(json.dumps(editions))
|
|
shutil.copyfile('build/candidate/web/editor.html','web/editor.html')
|
|
make_site.main('build/candidate/build/felucca.fwsc',m['version'],'build/new-preview',str(fw))
|
|
for sub in ('firmware','webapp/installer','webapp/editor'):
|
|
shutil.rmtree(pages/'preview'/sub)
|
|
shutil.copytree(Path('build/new-preview')/sub,pages/'preview'/sub)
|
|
if Path('build/candidate/web/vel.html').exists(): # (V10.6z5) the velocity diagnostic's page, from the candidate
|
|
(pages/'preview/webapp/vel').mkdir(parents=True,exist_ok=True)
|
|
shutil.copyfile('build/candidate/web/vel.html',pages/'preview/webapp/vel/index.html')
|
|
fw=pages/'preview/firmware';versions=json.loads((fw/'versions.json').read_text())
|
|
assert versions[0]['version']==m['version'] and len(versions)==min(len(prior)+1,make_site.KEEP_OLD+1) # (the oldest beyond KEEP_OLD drops off)
|
|
for name,h in old.items():assert not (fw/name).exists() or digest(fw/name)==h,'previous beta package changed'
|
|
assert all((fw/v['file']).exists() for v in versions),'a listed package is missing'
|
|
(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'))))
|
|
emu=Path('build/beta-emulator');wasm=emu/'felucca.wasm'
|
|
assert digest(wasm)==m['emulator_sha256'],'candidate emulator SHA256 mismatch'
|
|
assert wasm.read_bytes()[:8]==b'\x00asm\x01\x00\x00\x00','invalid WebAssembly'
|
|
html=(emu/'index.html').read_text()
|
|
assert '<small class="version">'+v+' (preview)</small>' in html,'emulator version mismatch'
|
|
(emu/'index.html').write_text(html.replace('Installer (approved version)','Installer (beta)'))
|
|
target=pages/'preview/emu'
|
|
if target.exists():shutil.rmtree(target)
|
|
shutil.copytree(emu,target)
|
|
if (pages/'emu-v/index.json').exists(): # (the version picker over every installer version: web/emu/picker.js)
|
|
(target/'index.html').write_text((target/'index.html').read_text().replace('</body>','<script src="../../emu-v/picker.js"></script>\n</body>',1))
|
|
(target/'SOURCE_COMMIT').write_text(m['source']+'\n')
|
|
(target/'SHA256SUMS').write_text(''.join(digest(p)+' '+p.relative_to(target).as_posix()+'\n' for p in sorted(target.rglob('*')) if p.is_file()))
|
|
assert before==protected(),'a public, public-emulator or non-preview editor file changed'
|
|
print('PASS exact beta emulator; public emulator unchanged')
|
|
print('PASS previous beta bytes preserved; public site and all non-beta files 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: voice-split-beta
|
|
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
|
|
|