mohan-bee/fitness-band
A 4-layer BLE wearable mainboard with Li-ion charging/protection, 3.3/1.8 V power regulation, motion and battery sensing, plus a folded 2-layer flex sensor board carrying MAX30102 optical and TMP117 temperature sensors.
- Version
- 0.0.2
- License
- unset
- Stars
- 0
scripts/package-release.py
from pathlib import Path
import hashlib,json,zipfile
root=Path(__file__).resolve().parents[1];release=root/'manufacturing/rev-b'
manifest=json.loads((release/'release-manifest.json').read_text())
for kind in ('main','flex'):
report=json.loads((root/f'validation/{kind}-native-drc.json').read_text())
assert not report['violations'] and not report['unconnected_items']
pcb=release/kind/f'{kind}.kicad_pcb'
assert hashlib.sha256(pcb.read_bytes()).hexdigest()==manifest[kind]['native_sha256']
snapshot=root/manifest[kind]['circuit_json_path']
assert hashlib.sha256(snapshot.read_bytes()).hexdigest()==manifest[kind]['circuit_json_sha256']
with zipfile.ZipFile(release/f'{kind}-fabrication.zip','w',zipfile.ZIP_DEFLATED) as z:
for p in sorted((release/kind/'gerbers').iterdir()):
if p.suffix.lower() not in ('.svg','.rpt'):z.write(p,p.name)
z.write(release/'FABRICATION.md','READ-FABRICATION.md')
z.write(release/'MANUFACTURING_STATUS.md','MANUFACTURING_STATUS.md')
checksums=[]
for p in sorted(release.rglob('*')):
if p.is_file() and p.name!='checksums.sha256' and p.suffix!='.kicad_prl':checksums.append(hashlib.sha256(p.read_bytes()).hexdigest()+' '+str(p.relative_to(release)))
(release/'checksums.sha256').write_text('\n'.join(checksums)+'\n')
handoff=root.parent/'fitness-band-rev-b-manufacturing.zip'
with zipfile.ZipFile(handoff,'w',zipfile.ZIP_DEFLATED) as z:
for p in sorted(release.rglob('*')):
if p.is_file() and p.suffix!='.kicad_prl':z.write(p,p.relative_to(release))
with zipfile.ZipFile(handoff) as z:assert z.testzip() is None
print(handoff, handoff.stat().st_size,'bytes')
out=root.parent/'fitness-band-rev-b-prototype.zip'
skip={'node_modules','.tscircuit','.claude','work','__pycache__'}
with zipfile.ZipFile(out,'w',zipfile.ZIP_DEFLATED) as z:
for p in sorted(root.rglob('*')):
rel=p.relative_to(root)
if not p.is_file() or any(part in skip for part in rel.parts) or p.suffix=='.kicad_prl' or p.name=='.DS_Store':continue
z.write(p,Path(root.name)/rel)
with zipfile.ZipFile(out) as z:assert z.testzip() is None
old=root.parent/'fitness-band-option-b.zip'
if old.exists():old.unlink()
print(out, out.stat().st_size,'bytes')