Skip to content

Commit 64fdd07

Browse files
authored
Merge pull request #224 from OpenKnots/fix/release-readme-table
fix(release): handle missing release index table gracefully
2 parents 5b9a5e5 + 9d43b4f commit 64fdd07

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

scripts/prepare-release.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,16 @@ function updateChangelog(rootDir: string, version: string, section: string): voi
352352
writeFileSync(changelogPath, content);
353353
}
354354

355-
function updateReleasesReadme(rootDir: string, version: string, shortDescription: string): void {
355+
function updateReleasesReadme(rootDir: string, version: string, shortDescription: string): boolean {
356356
const readmePath = resolve(rootDir, "docs/releases/README.md");
357357
let content = readFileSync(readmePath, "utf8");
358358

359359
// Find the table header separator line (| --- | --- | --- |)
360360
const separatorRe = /^\|[ -]+\|[ -]+\|[ -]+\|$/m;
361361
const match = content.match(separatorRe);
362362
if (!match || match.index === undefined) {
363-
fatal("Could not find the table in docs/releases/README.md");
363+
// No release index table found — skip gracefully
364+
return false;
364365
}
365366

366367
const insertAfter = content.indexOf("\n", match.index);
@@ -369,6 +370,7 @@ function updateReleasesReadme(rootDir: string, version: string, shortDescription
369370
content = content.slice(0, insertAfter + 1) + newRow + "\n" + content.slice(insertAfter + 1);
370371

371372
writeFileSync(readmePath, content);
373+
return true;
372374
}
373375

374376
// ---------------------------------------------------------------------------
@@ -613,13 +615,17 @@ async function main(): Promise<void> {
613615
log("OK", "Updated: CHANGELOG.md");
614616
}
615617

616-
// Update docs/releases/README.md
618+
// Update docs/releases/README.md (if it has a release index table)
617619
const shortDescription = summary.replace(/\.$/, "").slice(0, 60);
618620
if (dryRun) {
619-
log("--", "Would update: docs/releases/README.md");
621+
log("--", "Would update: docs/releases/README.md (if table exists)");
620622
} else {
621-
updateReleasesReadme(rootDir, version, shortDescription);
622-
log("OK", "Updated: docs/releases/README.md");
623+
const updated = updateReleasesReadme(rootDir, version, shortDescription);
624+
if (updated) {
625+
log("OK", "Updated: docs/releases/README.md");
626+
} else {
627+
log("--", "No release index table in docs/releases/README.md (skipped).");
628+
}
623629
}
624630
console.log("");
625631

@@ -724,8 +730,12 @@ async function main(): Promise<void> {
724730

725731
if (!skipCommit && !dryRun) {
726732
console.log(" Next steps:");
727-
console.log(` 1. Monitor the desktop release workflow: ${REPO_URL}/actions/workflows/release.yml`);
728-
console.log(` 2. Monitor the iOS TestFlight workflow: ${REPO_URL}/actions/workflows/release-ios.yml`);
733+
console.log(
734+
` 1. Monitor the desktop release workflow: ${REPO_URL}/actions/workflows/release.yml`,
735+
);
736+
console.log(
737+
` 2. Monitor the iOS TestFlight workflow: ${REPO_URL}/actions/workflows/release-ios.yml`,
738+
);
729739
console.log(` 3. Verify the GitHub Release: ${REPO_URL}/releases/tag/${tag}`);
730740
console.log(" 4. Test downloaded installers on each platform.");
731741
console.log(" 5. Verify auto-update from the previous version.");

0 commit comments

Comments
 (0)