hex/site/src/base.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

39 lines
1.9 KiB
TypeScript

// The site lives under /hex on anoma.ly (production) and dev.anoma.ly (dev), and
// the release files under /hex/files. Pages keep root-relative paths internally;
// these helpers add and remove the prefix at the edges.
export const BASE_PATH = "/hex"
export const FILES_PATH = `${BASE_PATH}/files`
// The Anomaly release service. Its dev stage (dev.anoma.ly/release) is only for
// testing the service itself, so both site environments read production.
export const RELEASE_SERVICE = "https://anoma.ly/release"
// Redirects to the latest dev channel Mac download (worker.ts).
export const DEV_DOWNLOAD_PATH = `${BASE_PATH}/download/dev`
// The dev builds' changelog (worker.ts, src/dev-notes.ts).
export const DEV_NOTES_PATH = `${BASE_PATH}/dev`
// The Release workflow publishes the dev builds' notes to this one-commit
// branch (publish-dev-notes.sh), which the Worker serves at
// `${FILES_PATH}/dev-notes.json` and renders at `DEV_NOTES_PATH`, so neither
// the app nor the changelog waits for a site deploy.
export const DEV_NOTES_URL = "https://raw.githubusercontent.com/anomalyco/hex/dev-notes/dev-notes.json"
// Redirects to the current release's file for a target (worker.ts).
export const DOWNLOAD_PATH = `${BASE_PATH}/download`
// The build mode (`--mode dev`) picks the environment; every other mode builds production.
export function hostForMode(mode: string | undefined): string {
return mode === "dev" ? "dev.anoma.ly" : "anoma.ly"
}
export function originForMode(mode: string | undefined): string {
return `https://${hostForMode(mode)}${BASE_PATH}`
}
export function withBase(path: string): string {
return `${BASE_PATH}${path}`
}
// Returns the site path for a request path, or undefined when it is outside the base.
export function stripBase(pathname: string): string | undefined {
if (pathname === BASE_PATH) return "/"
if (!pathname.startsWith(`${BASE_PATH}/`)) return undefined
return pathname.slice(BASE_PATH.length)
}