hex/site/src/dev-notes.ts
Dax 8201a4ce1c
ci: read release secrets from aws secrets manager (#1606)
* ci: read release secrets from aws secrets manager

* ci: read the linux signing key from hex/release/RELEASE_SIGNING_KEY

* ci: hex's own aur and homebrew keys; the signing cert has no password

* ci: the signing certificate has no password

* ci: use the shared aur and homebrew keys

* docs: the shared homebrew deploy key is anomaly-release

* docs: the shared homebrew deploy key is anomaly-release

* site: own /hex/files, drop the r2 write credential (#1611)

* site: own /hex/files for installers, appcast, and dev notes

The site build now copies install-linux.sh, install-windows.ps1, and
packaging/macos/legacy-appcast.xml into its Worker assets, so the same
Worker serves them at /hex/files with the Content-Type and Cache-Control
the bucket objects had. The Installers and Legacy appcast workflows,
r2-put.sh, and their R2 write credential are gone.

The dev notes move to the one-commit dev-notes branch, published by
Release's dev-notes job with GITHUB_TOKEN only; the Worker proxies that
file at /hex/files/dev-notes.json (falling back to the bucket copy until
the first dev release creates the branch) and renders /hex/dev from it.

Both site Workers now bind hex-production-files, read-only in code, for
the frozen 2.3.1 feeds and artifacts, which lets hex-dev-files go. The
Site build runs the installer test and appcast check the removed
workflows ran, and the verify job compares the served bytes.

* docs: the site owns /hex/files and needs no R2 write credential

Hosting, secrets, old clients, and Linux packages describe the built
installers and appcast, the dev-notes branch, and the read-only bucket.
2026-11-09 15:18:26 -05:00

114 lines
4.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// The dev channel's changelog at /hex/dev: what each dev build changed, from
// dev-notes.json on the Release workflow's dev-notes branch (see
// scripts/release-dev-notes.sh and .github/release/publish-dev-notes.sh). The
// worker fetches and renders it per request, so a new dev build shows without
// a site deploy.
export type DevNotes = {
schema: 1
builds: { version: string; commit: string; published_at: string; items: { title: string; url: string }[] }[]
}
const ITEM_URL = /^https:\/\/github\.com\/anomalyco\/hex\/(pull\/[0-9]+|commit\/[0-9a-f]{40})$/
function escape(text: string): string {
return text.replace(/[&<>"']/g, (character) => `&#${character.charCodeAt(0)};`)
}
// Keeps only well-formed builds and items; the page never trusts the file's shape.
export function parseDevNotes(value: unknown): DevNotes {
const builds: DevNotes["builds"] = []
const raw = (value as { builds?: unknown })?.builds
for (const build of Array.isArray(raw) ? raw : []) {
if (typeof build?.version !== "string" || !/^0\.0\.0-dev-[0-9]+$/.test(build.version)) continue
const items = (Array.isArray(build.items) ? build.items : []).filter(
(item: unknown): item is { title: string; url: string } =>
typeof (item as { title?: unknown })?.title === "string" &&
typeof (item as { url?: unknown })?.url === "string" &&
ITEM_URL.test((item as { url: string }).url),
)
builds.push({
version: build.version,
commit: typeof build.commit === "string" ? build.commit : "",
published_at: typeof build.published_at === "string" ? build.published_at : "",
items: items.map((item: { title: string; url: string }) => ({ title: item.title, url: item.url })),
})
}
return { schema: 1, builds }
}
function date(iso: string): string {
const parsed = new Date(iso)
if (Number.isNaN(parsed.getTime())) return ""
return parsed.toLocaleString("en-US", { timeZone: "America/New_York", dateStyle: "medium", timeStyle: "short" }) + " ET"
}
const REPOSITORY = "https://github.com/anomalyco/hex"
const COMMIT = /^[0-9a-f]{40}$/
// ?since=<version> (the app's What's new) shows only the builds after the
// one an install runs, with every commit in between on GitHub.
function since(notes: DevNotes, version: string | null): { builds: DevNotes["builds"]; summary: string } {
const all = { builds: notes.builds, summary: "" }
if (!version) return all
const index = notes.builds.findIndex((build) => build.version === version)
if (index <= 0) return all
const builds = notes.builds.slice(0, index)
const from = notes.builds[index].commit
const to = builds[0].commit
const compare = COMMIT.test(from) && COMMIT.test(to)
? ` <a href="${REPOSITORY}/compare/${from}...${to}">Every commit since ${escape(version)}</a> ·`
: ""
return {
builds,
summary: `<p class="since">Changes since ${escape(version)}, the build you run.${compare} <a href="/hex/dev">Every dev build</a></p>`,
}
}
export function renderDevNotes(notes: DevNotes, downloadPath: string, sinceVersion: string | null = null): string {
const shown = since(notes, sinceVersion)
const builds = shown.builds
.map((build) => {
const items = build.items.length
? `<ul>${build.items
.map((item) => `<li><a href="${escape(item.url)}">${escape(item.title)}</a></li>`)
.join("")}</ul>`
: `<p class="quiet">Internal changes only.</p>`
return `<section id="${escape(build.version)}"><h2><a href="#${escape(build.version)}">${escape(build.version)}</a></h2><p class="quiet">${escape(date(build.published_at))}</p>${items}</section>`
})
.join("")
return `<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hex dev builds</title>
<meta name="description" content="What changed in each dev build of Hex.">
<link rel="icon" href="/hex/favicon.svg" type="image/svg+xml">
<style>
body { margin: 0; background: #070707; color: #e8e8e8; font: 15px/1.55 Inter, ui-sans-serif, system-ui, sans-serif; }
main { max-width: 680px; margin: 0 auto; padding: 48px 20px 80px; }
h1 { font-size: 28px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0; }
section { border-top: 1px solid #222; padding: 20px 0; }
ul { margin: 10px 0 0; padding-left: 20px; }
li { margin: 4px 0; }
a { color: #e8e8e8; text-decoration-color: #555; text-underline-offset: 3px; }
a:hover { text-decoration-color: #e8e8e8; }
h2 a { text-decoration: none; }
.quiet { color: #8a8a8a; margin: 2px 0 0; }
.intro { margin: 0 0 28px; color: #b0b0b0; }
.since { margin: 0 0 12px; }
</style>
</head>
<body>
<main>
<h1>Hex dev builds</h1>
<p class="intro">What changed in each dev build. Dev builds update often and can break; <a href="/hex/">stable</a> is the safe choice. <a href="${escape(downloadPath)}">Download the latest Mac dev build</a>, or switch Settings › Update channel to Dev.</p>
${shown.summary}
${builds || `<p class="quiet">No dev build notes yet.</p>`}
</main>
</body>
</html>
`
}