Add versioning and harden deploy caching (v0.2.0)

Versioning:
- package.json is the single source of the version (0.2.0); the build
  injects it into the landing page and Storybook via src/version.ts
- Add CHANGELOG.md and a release section in the README

Deploy:
- Refuse to deploy uncommitted work unless --allow-dirty is passed
- Stamp each deploy with version.json and verify the live stamp
- Serve HTML and JSON with Cache-Control: no-cache and cache only the
  content-hashed assets/ folders long-term
- Return 404 for missing assets instead of index.html, which blanked
  the Storybook canvas for browsers holding a stale page
- Always restore the hardened .htaccess, even when a step fails
- Make the post-deploy PHP-off check real, build Storybook before
  checking for its index, and stop logging the session token
This commit is contained in:
thekhalidsha committed 2026-09-28 17:21:35 +05:30
1 parent 9d406d6d2a
commit dc5e6ff800
10 files changed
+224 -52

No files matched your search

+28 -2
View File
@@ -8,11 +8,15 @@ archive as the complete truth for the docroot and prunes everything else.
```bash
python3 scripts/deploy.py # build + package + upload + verify
python3 scripts/deploy.py --deploy-only # upload the existing build
python3 scripts/deploy.py --deploy-only # upload the existing build (must be built from HEAD)
python3 scripts/deploy.py --build-only # build and package, upload nothing
python3 scripts/deploy.py --dry-run # package and report, upload nothing
```
Commit before deploying. The script refuses to upload while the working tree
has uncommitted changes, so what is live always matches a commit. Pass
`--allow-dirty` to override.
## One-time setup
```bash
@@ -33,7 +37,29 @@ environment instead, which is what CI should do.
4. POST the base64 payload to it with a `Host` header for the subdomain,
pointed at the origin IP so Cloudflare is bypassed
5. The PHP extracts, then deletes anything the archive did not contain
6. Rewrite the hardened `.htaccess` and verify the site
6. Rewrite the hardened `.htaccess` (always, even if a step above failed),
confirm PHP is off again, and verify the site, including `/version.json`
## Caching
The root `.htaccess` sends `Cache-Control: no-cache`, so browsers revalidate
`index.html`, `docs/index.json` and Storybook's fixed-name manager bundles on
every visit. `package()` adds an `.htaccess` to `assets/` and `docs/assets/`
that caches those content-hashed files for a year. Missing asset URLs return
404 instead of falling back to `index.html`. A stale page that asks for a pruned
bundle then fails visibly, instead of receiving HTML and rendering an empty
Storybook canvas.
## Version stamp
Each deploy writes `version.json` at the docroot:
```json
{ "version": "0.2.0", "commit": "abc1234", "dirty": false, "built_at": "…" }
```
`verify()` checks that the live stamp matches the one just uploaded. To see
what is running, open `https://<your-subdomain>/version.json`.
## Why the archive can be authoritative