Add versioning system, changelog page, and release skill

Replace calver (YYYY.MM.DD+sha) with marketing versioning (X.Y.Z),
starting at 9.9.0. Add changelog page at /changelog with Keep a
Changelog parsing, pre-release banner, and expandable entries linked
to GitLab releases. Add VersionCheck component that shows a "What's
new" toast when the app version changes. Add release skill for
managing versioned releases with changelog and git tagging.
This commit is contained in:
Alex Gleason committed 2026-04-02 02:09:00 -05:00
1 parent 380e6f3b84
commit b7ce705b2b
20 files changed
+754 -43

No files matched your search

+2
View File
@@ -30,6 +30,7 @@ import { OfflineIndicator } from '@/components/OfflineIndicator';
import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt';
import { ErrorBoundary } from '@/components/ErrorBoundary';
import { LockdownModeDetector } from '@/components/LockdownModeDetector';
import { VersionCheck } from '@/components/VersionCheck';
import AppRouter from './AppRouter';
@@ -152,6 +153,7 @@ export function App() {
<DynamicFavicon />
<OfflineIndicator />
<PWAUpdatePrompt />
<VersionCheck />
<LockdownModeDetector />
<Suspense>
<AppRouter />
+2
View File
@@ -23,6 +23,7 @@ import { NIP19Page } from "./pages/NIP19Page";
import NotFound from "./pages/NotFound";
import { ProjectView } from "./pages/ProjectView";
import { SettingsLayout } from "./components/SettingsLayout";
import { ChangelogPage } from "./pages/ChangelogPage";
export function AppRouter() {
return (
@@ -49,6 +50,7 @@ export function AppRouter() {
<Route path="storage" element={<StorageSettings />} />
<Route path="about" element={<AboutSettings />} />
</Route>
<Route path="/changelog" element={<ChangelogPage />} />
<Route path="/project/:projectId" element={<ProjectView />} />
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
<Route path="/:nip19" element={<NIP19Page />} />
+67
View File
@@ -0,0 +1,67 @@
import { useEffect } from 'react';
import { Link } from 'react-router-dom';
import { toast } from '@/hooks/useToast';
import { ToastAction } from '@/components/ui/toast';
import { parseChangelog } from '@/lib/changelog';
const STORAGE_KEY = 'shakespeare:app-version';
/** Fetch the first changelog item for the given version (or the latest entry). */
async function fetchChangelogExcerpt(version: string): Promise<string | undefined> {
try {
const res = await fetch('/CHANGELOG.md');
if (!res.ok) return undefined;
const markdown = await res.text();
const entries = parseChangelog(markdown);
// Try to find the entry matching the current version, otherwise use the first entry.
const entry = entries.find((e) => e.version === version) ?? entries[0];
if (!entry) return undefined;
// Return the first item from the first section.
return entry.sections[0]?.items[0];
} catch {
return undefined;
}
}
/** Compares the running app version against localStorage and shows a toast when the version changes. */
export function VersionCheck() {
useEffect(() => {
const currentVersion = import.meta.env.VERSION;
if (!currentVersion) return;
const storedVersion = localStorage.getItem(STORAGE_KEY);
localStorage.setItem(STORAGE_KEY, currentVersion);
if (storedVersion && storedVersion !== currentVersion) {
// Show the toast immediately, then enrich it with a changelog excerpt.
const { update, id } = toast({
title: `What's new in v${currentVersion}`,
action: (
<ToastAction altText="View changelog" asChild>
<Link to="/changelog">See all</Link>
</ToastAction>
),
});
fetchChangelogExcerpt(currentVersion).then((excerpt) => {
if (excerpt) {
update({
id,
title: `What's new in v${currentVersion}`,
description: excerpt,
action: (
<ToastAction altText="View changelog" asChild>
<Link to="/changelog">See all</Link>
</ToastAction>
),
});
}
});
}
}, []);
return null;
}
+81
View File
@@ -0,0 +1,81 @@
/** Category types from Keep a Changelog format. */
type ChangelogCategory = 'Added' | 'Changed' | 'Deprecated' | 'Removed' | 'Fixed' | 'Security';
/** A single version entry in the changelog. */
interface ChangelogEntry {
version: string;
date: string;
sections: {
category: ChangelogCategory;
items: string[];
}[];
}
/** Apply basic typographic transformations to a changelog item string. */
function prettify(text: string): string {
return text
.replace(/ -- /g, ' \u2014 ') // space-dash-dash-space → em dash
.replace(/(\w)--(\w)/g, '$1\u2013$2') // word--word → en dash
.replace(/ (\S+)$/, '\u00A0$1'); // prevent orphaned last word
}
/**
* Parse a Keep a Changelog formatted markdown string into structured data.
* @see https://keepachangelog.com/
*/
function parseChangelog(markdown: string): ChangelogEntry[] {
const entries: ChangelogEntry[] = [];
let current: ChangelogEntry | null = null;
let currentCategory: ChangelogCategory | null = null;
for (const line of markdown.split('\n')) {
// Match version heading: ## [X.Y.Z] - YYYY-MM-DD
const versionMatch = line.match(/^## \[([^\]]+)\]\s*-\s*(.+)$/);
if (versionMatch) {
current = { version: versionMatch[1], date: versionMatch[2].trim(), sections: [] };
entries.push(current);
currentCategory = null;
continue;
}
// Match category heading: ### Added, ### Changed, etc.
const categoryMatch = line.match(/^### (.+)$/);
if (categoryMatch && current) {
currentCategory = categoryMatch[1].trim() as ChangelogCategory;
current.sections.push({ category: currentCategory, items: [] });
continue;
}
// Match list item: - Description
const itemMatch = line.match(/^- (.+)$/);
if (itemMatch && current) {
const section = current.sections[current.sections.length - 1];
if (section) {
section.items.push(prettify(itemMatch[1]));
} else {
// Item without a category heading — treat as "Changed"
current.sections.push({ category: 'Changed', items: [prettify(itemMatch[1])] });
}
continue;
}
// Lines that don't start with "- " but aren't blank may be a continuation or
// freeform text after the version heading (e.g. "Initial release of Shakespeare").
const trimmed = line.trim();
if (trimmed && current && !trimmed.startsWith('#')) {
const section = current.sections[current.sections.length - 1];
if (section) {
// Append to last item or add new item
section.items.push(prettify(trimmed));
} else {
// Freeform text under version with no category — store in a generic section
current.sections.push({ category: 'Changed', items: [prettify(trimmed)] });
}
}
}
return entries;
}
export { parseChangelog };
export type { ChangelogEntry, ChangelogCategory };
+1 -1
View File
@@ -1,6 +1,6 @@
import { z } from 'zod';
import { NPool, NRelay1 } from '@nostrify/nostrify';
import type { NostrEvent, NostrSigner } from '@nostrify/nostrify';
import type { NostrSigner } from '@nostrify/nostrify';
import { DotAI } from '../DotAI';
import { buildAppEvent } from '../appEvent';
+1
View File
@@ -239,6 +239,7 @@
"aboutShakespeareDescription": "Information about Shakespeare",
"mirrors": "Mirrors",
"mirrorsDescription": "Shakespeare is available at multiple mirror URLs for redundancy and accessibility.",
"changelog": "Changelog",
"sourceCode": "Source Code",
"description": "Description",
"license": "License",
+1
View File
@@ -267,6 +267,7 @@
"aboutShakespeareDescription": "Bayani game da Shakespeare.",
"mirrors": "Madubai",
"mirrorsDescription": "Shakespeare yana samuwa a URLs masu yawa don inganci da samun dama.",
"changelog": "Tarihin Canje-canje",
"sourceCode": "Lambar Tushe",
"description": "Bayanin",
"license": "Lasisi",
+1
View File
@@ -267,6 +267,7 @@
"aboutShakespeareDescription": "Ozi gbasara Shakespeare.",
"mirrors": "Enyo",
"mirrorsDescription": "Shakespeare dị na ọtụtụ URL enyo maka nnọchi na nnweta.",
"changelog": "Ndekọ Mgbanwe",
"sourceCode": "Koodu Isi",
"description": "Nkọwa",
"license": "Ikike",
+1
View File
@@ -276,6 +276,7 @@
"aboutShakespeareDescription": "Informações sobre o Shakespeare.",
"mirrors": "Espelhos",
"mirrorsDescription": "Shakespeare está disponível em vários URLs espelhados para redundância e acessibilidade.",
"changelog": "Registro de alterações",
"sourceCode": "Código-fonte",
"description": "Descrição",
"license": "Licença",
+1
View File
@@ -267,6 +267,7 @@
"aboutShakespeareDescription": "Alaye nipa Shakespeare.",
"mirrors": "Awọn Digi",
"mirrorsDescription": "Shakespeare wa ni awọn URL digi pupọ fun aredundan ati iraye si.",
"changelog": "Akọsilẹ Ayipada",
"sourceCode": "Koodu Orisun",
"description": "Apejuwe",
"license": "Iwe-aṣẹ",
+1
View File
@@ -276,6 +276,7 @@
"aboutShakespeareDescription": "关于Shakespeare的信息。",
"mirrors": "镜像",
"mirrorsDescription": "Shakespeare可通过多个镜像URL访问,以确保冗余和可访问性。",
"changelog": "更新日志",
"sourceCode": "源代码",
"description": "描述",
"license": "许可证",
+21 -4
View File
@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Info, ExternalLink, Loader2, AlertTriangle, Code, Globe } from 'lucide-react';
import { Link } from 'react-router-dom';
import { Info, ExternalLink, Loader2, AlertTriangle, Code, Globe, ScrollText } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
@@ -97,6 +98,22 @@ export function AboutSettings() {
</AccordionItem>
</Accordion>
{/* Changelog */}
<Card>
<CardContent className="p-0">
<Button
variant="ghost"
className="w-full h-12 flex items-center gap-2 justify-start text-base"
asChild
>
<Link to="/changelog">
<ScrollText className="!size-5 text-muted-foreground" />
{t('changelog')}
</Link>
</Button>
</CardContent>
</Card>
{/* Project Information */}
<Card>
<CardContent className="p-0">
@@ -148,9 +165,9 @@ export function AboutSettings() {
</div>
{import.meta.env.VERSION && (
<div className="text-center text-xs text-muted-foreground/60 pt-4">
v{import.meta.env.VERSION}
</div>
<Link to="/changelog" className="block text-center text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors select-none pt-4 pb-2">
v{import.meta.env.VERSION}{import.meta.env.COMMIT_TAG ? '' : '+'} ({new Date(import.meta.env.BUILD_DATE).toLocaleDateString()})
</Link>
)}
</SettingsPageLayout>
);
+323
View File
@@ -0,0 +1,323 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Link } from 'react-router-dom';
import { useSeoMeta } from '@unhead/react';
import { ArrowLeft, Bug, FlaskConical, Minus, Package, Plus, RefreshCw, ShieldAlert } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { parseChangelog } from '@/lib/changelog';
import type { ChangelogCategory, ChangelogEntry } from '@/lib/changelog';
const GITLAB_REPO = 'https://gitlab.com/soapbox-pub/shakespeare';
/** Per-category icon + color used as inline list bullets. */
const CATEGORY_STYLES: Record<ChangelogCategory, { icon: typeof Plus; colorClass: string }> = {
Added: { icon: Plus, colorClass: 'text-emerald-600 dark:text-emerald-400' },
Changed: { icon: RefreshCw, colorClass: 'text-blue-600 dark:text-blue-400' },
Deprecated: { icon: Package, colorClass: 'text-orange-600 dark:text-orange-400' },
Removed: { icon: Minus, colorClass: 'text-red-600 dark:text-red-400' },
Fixed: { icon: Bug, colorClass: 'text-amber-600 dark:text-amber-400' },
Security: { icon: ShieldAlert, colorClass: 'text-purple-600 dark:text-purple-400' },
};
/** Format "2026-03-26" as a readable date string. */
function formatDate(raw: string): string {
const date = new Date(raw + 'T00:00:00');
if (isNaN(date.getTime())) return raw;
return date.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });
}
const commitSha = import.meta.env.COMMIT_SHA;
const commitTag = import.meta.env.COMMIT_TAG;
const buildDate = import.meta.env.BUILD_DATE;
const isPreRelease = !commitTag;
export function ChangelogPage() {
const [content, setContent] = useState<string | null>(null);
const [error, setError] = useState(false);
useSeoMeta({
title: 'Changelog | Shakespeare',
description: "What's new in Shakespeare",
});
useEffect(() => {
fetch('/CHANGELOG.md')
.then((res) => {
if (!res.ok) throw new Error(res.statusText);
return res.text();
})
.then(setContent)
.catch(() => setError(true));
}, []);
const entries = useMemo(() => (content ? parseChangelog(content) : []), [content]);
const latestVersion = entries[0]?.version;
return (
<main className="min-h-screen bg-background">
{/* Header */}
<div className="border-b">
<div className="max-w-2xl mx-auto px-4 py-3 flex items-center gap-3">
<Button variant="ghost" size="sm" className="h-8 w-8 p-0" asChild>
<Link to="/settings/about">
<ArrowLeft className="size-4" />
</Link>
</Button>
<h1 className="text-lg font-semibold">Changelog</h1>
</div>
</div>
<div className="max-w-2xl mx-auto px-4 pt-3 pb-16 space-y-4">
{error ? (
<p className="text-sm text-muted-foreground pt-4">Failed to load changelog.</p>
) : content === null ? (
<ChangelogSkeleton />
) : entries.length === 0 ? (
<p className="text-sm text-muted-foreground pt-4">No releases yet.</p>
) : (
<>
{isPreRelease && latestVersion && <PreReleaseBanner latestVersion={latestVersion} />}
<LatestRelease entry={entries[0]} />
{entries.length > 1 && (
<>
<div className="flex items-center gap-3 pt-4 pb-1">
<div className="h-px flex-1 bg-border" />
<span className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Past releases</span>
<div className="h-px flex-1 bg-border" />
</div>
{entries.slice(1).map((entry) => (
<ChangelogEntryCard key={entry.version} entry={entry} />
))}
</>
)}
</>
)}
</div>
</main>
);
}
/** Hero treatment for the most recent release — no card, centered version + date. */
function LatestRelease({ entry }: { entry: ChangelogEntry }) {
const contentRef = useRef<HTMLUListElement>(null);
const [overflows, setOverflows] = useState(false);
const [expanded, setExpanded] = useState(false);
const measure = useCallback(() => {
const el = contentRef.current;
if (el) setOverflows(el.scrollHeight > ENTRY_MAX_HEIGHT);
}, []);
useEffect(() => {
measure();
window.addEventListener('resize', measure);
return () => window.removeEventListener('resize', measure);
}, [measure]);
return (
<div className="pt-2 pb-1 px-4">
{/* Big centered version + date */}
<a
href={`${GITLAB_REPO}/-/releases/v${entry.version}`}
target="_blank"
rel="noopener noreferrer"
className="block text-center text-2xl font-bold tracking-tight hover:underline"
>
v{entry.version}
</a>
<a
href={`${GITLAB_REPO}/-/releases/v${entry.version}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors mt-1"
>
{formatDate(entry.date)}
</a>
{/* Items */}
<div className="relative mt-4">
<ul
ref={contentRef}
style={!expanded && overflows ? { maxHeight: ENTRY_MAX_HEIGHT, overflow: 'hidden' } : undefined}
className="space-y-2.5"
>
{entry.sections.flatMap((section) => {
const style = CATEGORY_STYLES[section.category] ?? CATEGORY_STYLES.Changed;
const Icon = style.icon;
return section.items.map((item, i) => (
<li key={`${section.category}-${i}`} className="flex gap-2 text-base text-foreground/90">
<Tooltip>
<TooltipTrigger asChild>
<Icon className={`size-4 shrink-0 mt-1 cursor-default ${style.colorClass}`} />
</TooltipTrigger>
<TooltipContent side="left">{section.category}</TooltipContent>
</Tooltip>
<span>{item}</span>
</li>
));
})}
</ul>
{!expanded && overflows && (
<div className="absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-background to-transparent pointer-events-none" />
)}
</div>
{overflows && (
<button
className="w-full text-sm text-primary hover:underline mt-1"
onClick={() => setExpanded((v) => !v)}
>
{expanded ? 'Show less' : 'Read more'}
</button>
)}
</div>
);
}
const ENTRY_MAX_HEIGHT = 240; // px — entries taller than this get a "Read more" button
/** A single changelog release card with truncation for long entries. */
function ChangelogEntryCard({ entry }: { entry: ChangelogEntry }) {
const contentRef = useRef<HTMLUListElement>(null);
const [overflows, setOverflows] = useState(false);
const [expanded, setExpanded] = useState(false);
const measure = useCallback(() => {
const el = contentRef.current;
if (el) setOverflows(el.scrollHeight > ENTRY_MAX_HEIGHT);
}, []);
useEffect(() => {
measure();
window.addEventListener('resize', measure);
return () => window.removeEventListener('resize', measure);
}, [measure]);
return (
<div className="rounded-2xl border border-border overflow-hidden">
{/* Version header */}
<div className="flex items-center gap-3 px-4 py-3">
<a
href={`${GITLAB_REPO}/-/releases/v${entry.version}`}
target="_blank"
rel="noopener noreferrer"
className="font-semibold text-sm hover:underline"
>
v{entry.version}
</a>
<a
href={`${GITLAB_REPO}/-/releases/v${entry.version}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors ml-auto"
>
<span>{formatDate(entry.date)}</span>
</a>
</div>
{/* Items */}
<div className="relative">
<ul
ref={contentRef}
style={!expanded && overflows ? { maxHeight: ENTRY_MAX_HEIGHT, overflow: 'hidden' } : undefined}
className="px-4 py-3 space-y-2.5"
>
{entry.sections.flatMap((section) => {
const style = CATEGORY_STYLES[section.category] ?? CATEGORY_STYLES.Changed;
const Icon = style.icon;
return section.items.map((item, i) => (
<li key={`${section.category}-${i}`} className="flex gap-2 text-sm text-foreground/90">
<Tooltip>
<TooltipTrigger asChild>
<Icon className={`size-3.5 shrink-0 mt-[3px] cursor-default ${style.colorClass}`} />
</TooltipTrigger>
<TooltipContent side="left">{section.category}</TooltipContent>
</Tooltip>
<span>{item}</span>
</li>
));
})}
</ul>
{!expanded && overflows && (
<div className="absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-background to-transparent pointer-events-none" />
)}
</div>
{overflows && (
<button
className="w-full text-sm text-primary hover:underline py-2"
onClick={() => setExpanded((v) => !v)}
>
{expanded ? 'Show less' : 'Read more'}
</button>
)}
</div>
);
}
/** Banner shown at the top of the changelog for untagged (pre-release) builds. */
function PreReleaseBanner({ latestVersion }: { latestVersion: string }) {
return (
<div className="rounded-2xl border border-dashed border-amber-500/50 bg-amber-50/50 dark:bg-amber-950/20 px-4 py-3 space-y-1.5">
<div className="flex items-center gap-2">
<FlaskConical className="size-4 text-amber-600 dark:text-amber-400 shrink-0" />
<span className="text-sm font-medium text-amber-800 dark:text-amber-300">Pre-release build</span>
{commitSha && buildDate && (
<a
href={`${GITLAB_REPO}/-/commit/${commitSha}`}
target="_blank"
rel="noopener noreferrer"
className="ml-auto text-[11px] text-amber-600/70 dark:text-amber-400/70 hover:text-amber-800 dark:hover:text-amber-300 transition-colors"
>
{formatDate(buildDate.split('T')[0])}
</a>
)}
</div>
<p className="text-xs text-amber-700/80 dark:text-amber-400/70">
This build contains changes not yet included in a release.{' '}
<a
href={`${GITLAB_REPO}/-/compare/v${latestVersion}...${commitSha || 'main'}`}
target="_blank"
rel="noopener noreferrer"
className="underline underline-offset-2 hover:text-amber-900 dark:hover:text-amber-200 transition-colors"
>
View unreleased changes
</a>
</p>
</div>
);
}
function ChangelogSkeleton() {
return (
<div className="space-y-4 pt-1">
{[1, 2].map((i) => (
<div key={i} className="rounded-2xl border border-border overflow-hidden">
<div className="flex items-center gap-3 px-4 py-3">
<Skeleton className="size-4 rounded" />
<Skeleton className="h-4 w-16" />
<div className="ml-auto flex items-center gap-1.5">
<Skeleton className="size-3.5 rounded" />
<Skeleton className="h-3 w-24" />
</div>
</div>
<div className="px-4 py-3 space-y-2">
<Skeleton className="h-4 w-16 rounded-full" />
<Skeleton className="h-4 w-full ml-3" />
<Skeleton className="h-4 w-4/5 ml-3" />
<Skeleton className="h-4 w-3/5 ml-3" />
</div>
</div>
))}
</div>
);
}
export default ChangelogPage;
+12 -1
View File
@@ -1,2 +1,13 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-pwa/client" />
/// <reference types="vite-plugin-pwa/client" />
interface ImportMetaEnv {
/** Marketing version from package.json (e.g., "9.9.0"). */
readonly VERSION: string;
/** ISO 8601 timestamp of when the app was built (e.g., "2026-04-02T19:42:00.000Z"). */
readonly BUILD_DATE: string;
/** Short git commit SHA (e.g., "c1266823"). Empty string if unavailable. */
readonly COMMIT_SHA: string;
/** Git tag for the current commit (e.g., "v9.9.0"). Empty string if untagged (pre-release build). */
readonly COMMIT_TAG: string;
}