// Cut a ChronVer release: compute the next version, prepend a changelog section // for the pending commits, and write the version to package.json. // // deno task release # e.g. 2026.07.16, then 2026.07.16.1 same day // deno task release --break # append a -break suffix (breaking change) // deno task release --feature # append a -feature suffix (feature branch) // // This only edits CHANGELOG.md and package.json. Review the generated changelog // (it is a draft — curate it), then commit both with jj. Suggested description: // `release `. The version then rides along into `deno task image`. import { nextVersion } from "./version.ts"; import { pendingCommits, renderSection } from "./changelog.ts"; const PKG = new URL("../package.json", import.meta.url); const CHANGELOG = new URL("../CHANGELOG.md", import.meta.url); const PREAMBLE = `# Changelog All notable changes to Quantum are documented here. Versions follow [ChronVer](https://chronver.org); the format follows [Keep a Changelog](https://keepachangelog.com). `; const suffix = Deno.args.includes("--break") ? "break" : Deno.args.includes("--feature") ? "feature" : ""; const version = await nextVersion(suffix); // Build the new section from commits since the last release. const section = renderSection(version, await pendingCommits()); // Prepend it: keep the preamble, then the new section, then the prior sections. let prior = ""; try { const existing = await Deno.readTextFile(CHANGELOG); const firstHeading = existing.indexOf("## "); prior = firstHeading === -1 ? "" : existing.slice(firstHeading); } catch { // No CHANGELOG.md yet — first release creates it. } const changelog = `${PREAMBLE}\n${section}\n${prior}`.trimEnd() + "\n"; await Deno.writeTextFile(CHANGELOG, changelog); // Bump package.json (source of truth), preserving tab indentation. const pkg = JSON.parse(await Deno.readTextFile(PKG)); const previous = pkg.version; pkg.version = version; await Deno.writeTextFile(PKG, JSON.stringify(pkg, null, "\t") + "\n"); console.log(`Released ${version} (was ${previous}).`); console.log("Updated CHANGELOG.md and package.json."); console.log("Next: review/curate CHANGELOG.md, then commit both"); console.log( ` (e.g. \`jj describe -m "release ${version}"\`), then \`deno task image\`.`, );