Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Release pipeline: scripts/release.mjs assembles signed bento.page site; RELEASING runbook

nyblnet462a887a8ef6
diff --git a/.gitignore b/.gitignore
index ff1e88fe..3e7cbba0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ testing/
# os cruft
.DS_Store
*.tsbuildinfo
+site/
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
new file mode 100644
index 00000000..9e2a3f07
--- /dev/null
+++ b/docs/RELEASING.md
@@ -0,0 +1,61 @@
+# Releasing Bento Slides
+
+Releases are cut **locally** — the signing key never leaves the maintainer's
+machine, and the signed bytes are exactly the served bytes (no CI rebuild can
+drift from the manifest hash). Shipped files check
+`https://bento.page/releases/slides/manifest.json` (user-initiated only) and
+verify the manifest signature against the public key embedded in every shell.
+
+## One-time setup
+
+1. **Signing key** (already done): `node scripts/keygen.mjs` →
+ `~/.bento/release-key.json`. Keep an offline backup (password manager or
+ printed). Losing it orphans the update channel for every shipped file;
+ leaking it hands the update channel to an attacker. Never commit it, never
+ put it in CI secrets.
+2. **GitHub repo + Pages**: push this repo, then Settings → Pages → deploy
+ from the `gh-pages` branch (root). Set custom domain `bento.page`,
+ tick *Enforce HTTPS* (mandatory for `.page` anyway).
+3. **DNS at the registrar** for the apex `bento.page`:
+ - `A` records → `185.199.108.153`, `185.199.109.153`, `185.199.110.153`, `185.199.111.153`
+ - `AAAA` records → `2606:50c0:8000::153`, `2606:50c0:8001::153`, `2606:50c0:8002::153`, `2606:50c0:8003::153`
+ - Optional `www` `CNAME` → `<user>.github.io`
+4. **Verify the domain on GitHub** (Settings → Pages → Verified domains: add
+ the `_github-pages-challenge-<user>` TXT record it gives you). This
+ prevents Pages domain takeover if the site is ever unconfigured.
+
+## Cutting a release
+
+1. Bump `slides/package.json` version (this becomes `APP_VERSION` in the
+ shell and the manifest version — single source of truth).
+2. Commit, tag: `git tag vX.Y.Z`.
+3. `node scripts/release.mjs` — builds, signs, assembles `./site/`
+ (CNAME, landing page, live demo, download, signed manifest).
+4. Publish `./site/` to the `gh-pages` branch:
+
+ ```sh
+ git worktree add /tmp/bento-pages gh-pages # first time: git worktree add --orphan -b gh-pages /tmp/bento-pages
+ rm -rf /tmp/bento-pages/*
+ cp -R site/* /tmp/bento-pages/
+ git -C /tmp/bento-pages add -A
+ git -C /tmp/bento-pages commit -m "release vX.Y.Z"
+ git push origin gh-pages
+ git worktree remove /tmp/bento-pages
+ ```
+
+5. Also attach `site/releases/slides/Bento_Slides.bento.html` to a GitHub
+ Release for the tag — download counts, release-watch notifications, and a
+ permanent per-version archive.
+6. Sanity check: open the PREVIOUS version's file, About (topbar logo) →
+ Check for updates → should offer the new version, and the downloaded copy
+ must boot with the document intact.
+
+## Rules
+
+- Never edit files on `gh-pages` by hand — the manifest signature covers the
+ shell's exact bytes; any drift bricks the update check (integrity refusal).
+- Version only goes up. Shipped files refuse manifests that aren't strictly
+ newer than themselves (downgrade-replay protection), so a "rollback" is a
+ new higher version that reverts the code.
+- The update channel ships **signed code**; future sync/collab channels ship
+ **inert data**. Never blur the two.
diff --git a/scripts/release.mjs b/scripts/release.mjs
new file mode 100644
index 00000000..11b2ec14
--- /dev/null
+++ b/scripts/release.mjs
@@ -0,0 +1,90 @@
+#!/usr/bin/env node
+// Cut a Bento Slides release: build the shell, sign the manifest, and
+// assemble the complete static site for bento.page into ./site/.
+//
+// node scripts/release.mjs [--no-build] [--key path]
+//
+// Output (publish ./site/ to GitHub Pages — see docs/RELEASING.md):
+// site/
+// CNAME bento.page
+// index.html placeholder landing page
+// slides/index.html live demo (the shell itself)
+// releases/slides/Bento_Slides.bento.html the download
+// releases/slides/manifest.json signed update manifest
+//
+// The bytes that get SIGNED are the bytes that get SERVED — everything is
+// staged from one local build, so the manifest sha256 always matches the
+// shell at releases/. (This is why releases are cut locally, not in CI:
+// the signing key never leaves this machine, and there is no risk of a CI
+// rebuild producing different bytes than what was signed.)
+
+import { execFileSync } from 'node:child_process'
+import { cpSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const root = dirname(dirname(fileURLToPath(import.meta.url)))
+const args = process.argv.slice(2)
+const opt = (name, fallback) => {
+ const i = args.indexOf(`--${name}`)
+ return i >= 0 && args[i + 1] ? args[i + 1] : fallback
+}
+
+const version = JSON.parse(readFileSync(join(root, 'slides/package.json'), 'utf8')).version
+const shellSrc = join(root, 'slides/dist-single/Bento_Slides.bento.html')
+const site = join(root, 'site')
+
+if (!args.includes('--no-build')) {
+ console.log(`Building v${version}…`)
+ execFileSync('npm', ['run', 'build:single'], { cwd: join(root, 'slides'), stdio: 'inherit' })
+}
+
+rmSync(site, { recursive: true, force: true })
+mkdirSync(join(site, 'releases/slides'), { recursive: true })
+mkdirSync(join(site, 'slides'), { recursive: true })
+
+cpSync(shellSrc, join(site, 'releases/slides/Bento_Slides.bento.html'))
+// The live demo IS the shell — opening it boots the editor with the starter deck.
+cpSync(shellSrc, join(site, 'slides/index.html'))
+
+// Sign the manifest against the staged bytes.
+const signArgs = [
+ join(root, 'scripts/sign-release.mjs'),
+ join(site, 'releases/slides/Bento_Slides.bento.html'),
+ '--out', join(site, 'releases/slides/manifest.json'),
+]
+const key = opt('key', null)
+if (key) signArgs.push('--key', key)
+execFileSync('node', signArgs, { stdio: 'inherit' })
+
+writeFileSync(join(site, 'CNAME'), 'bento.page\n')
+
+// Placeholder landing page — replaced by the real one before public launch.
+writeFileSync(
+ join(site, 'index.html'),
+ `<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Bento — the office suite that fits in a file</title>
+<style>
+ body { font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ max-width: 640px; margin: 12vh auto; padding: 0 24px; color: #1e2a3a; }
+ h1 { font-size: 28px; } a { color: #b87400; }
+ .apps { margin-top: 2em; } .soon { color: #8a94a3; }
+</style>
+<h1>🍱 Bento</h1>
+<p>An office suite where every document is a single, self-contained HTML file —
+data, viewer and editor together. Open it anywhere, edit it, and it saves itself.
+No install, no account, no cloud.</p>
+<div class="apps">
+ <p><b>Slides</b> — <a href="/slides/">try it in your browser</a> or
+ <a href="/releases/slides/Bento_Slides.bento.html" download="Bento_Slides.bento.html">download
+ the app</a> (one HTML file — that's all of it).</p>
+ <p class="soon"><b>Docs</b> — in development · <b>Sheets</b> — planned</p>
+</div>
+`,
+)
+
+console.log(`\nSite assembled for v${version}:`)
+execFileSync('find', [site, '-type', 'f'], { stdio: 'inherit' })
+console.log('\nPublish ./site/ to the gh-pages branch (docs/RELEASING.md).')