fix(release): publish reviewed release PR merges
This commit is contained in:
@@ -73,6 +73,14 @@ function readCommits(text) {
|
||||
breaking:
|
||||
/^[a-z]+(?:\([^)]*\))?!: /u.test(title) ||
|
||||
/^BREAKING(?: CHANGE|-CHANGE):\s*\S/mu.test(body),
|
||||
breakingNotes: Array.from(
|
||||
body
|
||||
.replace(/\r\n/gu, "\n")
|
||||
.matchAll(
|
||||
/^BREAKING(?: CHANGE|-CHANGE):[ \t]*(\S[^\n]*(?:\n(?!\n|[A-Za-z-]+: )[^\n]+)*)/gmu,
|
||||
),
|
||||
(match) => match[1].replace(/\s+/gu, " ").trim(),
|
||||
),
|
||||
});
|
||||
}
|
||||
return commits;
|
||||
@@ -207,8 +215,15 @@ async function validateCandidate(git, sha, version, commits) {
|
||||
version,
|
||||
);
|
||||
const breakingNotes = breakingSection(notes);
|
||||
const normalizedBreakingNotes = breakingNotes.replace(/\s+/gu, " ");
|
||||
const missingBreaking = commits.filter(
|
||||
(commit) => commit.breaking && !referencesCommit(breakingNotes, commit),
|
||||
(commit) =>
|
||||
commit.breaking &&
|
||||
!referencesCommit(breakingNotes, commit) &&
|
||||
(commit.breakingNotes.length === 0 ||
|
||||
commit.breakingNotes.some(
|
||||
(note) => !normalizedBreakingNotes.includes(note),
|
||||
)),
|
||||
);
|
||||
if (missingBreaking.length > 0) {
|
||||
throw new Error(
|
||||
@@ -224,14 +239,24 @@ export async function inspectReleaseCheckpoint(git, options) {
|
||||
.object({
|
||||
phase: z.enum(["prepare", "publish"]),
|
||||
stage: z.enum(["source", "candidate"]),
|
||||
releaseBranch: z.string().startsWith("release/"),
|
||||
releaseBranch: z.union([
|
||||
z.literal("main"),
|
||||
z.string().startsWith("release/"),
|
||||
]),
|
||||
sourceSha: shaSchema,
|
||||
candidateSha: shaSchema.optional(),
|
||||
})
|
||||
.parse(options);
|
||||
if (releaseBranch === "main" && (phase !== "publish" || stage !== "source")) {
|
||||
throw new Error(
|
||||
"Main publication validates its reviewed merged source SHA.",
|
||||
);
|
||||
}
|
||||
const expectedVersion = releaseVersion(
|
||||
releaseBranch.slice("release/".length),
|
||||
"release/VERSION",
|
||||
releaseBranch === "main"
|
||||
? (await readJson(git, sourceSha, "package.json", versionSchema)).version
|
||||
: releaseBranch.slice("release/".length),
|
||||
releaseBranch === "main" ? "reviewed main release" : "release/VERSION",
|
||||
);
|
||||
if (phase === "publish" && stage === "candidate") {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user