Skip to content

Commit 89ec3d9

Browse files
committed
scripts: add explicit confirmation before landing release PR
1 parent 50ed0c2 commit 89ec3d9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

scripts/src/release.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import pc from "picocolors";
33
import { execSync } from "node:child_process";
44
import { readFileSync, writeFileSync } from "node:fs";
55
import { join } from "node:path";
6+
import * as readline from "node:readline";
67

78
const REPO_ROOT = join(import.meta.dirname, "..", "..");
89

@@ -55,6 +56,20 @@ function error(message: string): never {
5556
process.exit(1);
5657
}
5758

59+
async function confirm(message: string): Promise<boolean> {
60+
const rl = readline.createInterface({
61+
input: process.stdin,
62+
output: process.stdout,
63+
});
64+
65+
return new Promise((resolve) => {
66+
rl.question(pc.yellow(`? ${message} (y/N) `), (answer) => {
67+
rl.close();
68+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
69+
});
70+
});
71+
}
72+
5873
async function pollUntil(
5974
check: () => boolean | Promise<boolean>,
6075
options: {
@@ -226,6 +241,16 @@ function createAndPushPR(version: string): string {
226241
async function waitForChecksAndMerge(prUrl: string): Promise<void> {
227242
const prNumber = prUrl.split("/").pop();
228243

244+
console.log();
245+
console.log(pc.bold("Please review the pull request before proceeding:"));
246+
console.log(pc.cyan(` ${prUrl}`));
247+
console.log();
248+
249+
const confirmed = await confirm("Enable auto-merge and continue with the release?");
250+
if (!confirmed) {
251+
error("Release cancelled by user");
252+
}
253+
229254
logStarted("Enabling auto-merge...");
230255
exec(`gh pr merge ${prNumber} --rebase --auto --delete-branch`);
231256
logCompleted("Auto-merge enabled");

0 commit comments

Comments
 (0)