fix(bogus): this is crap
This commit is contained in:
@@ -56,7 +56,7 @@ const result = spawnSync(
|
||||
"CHANGELOG.md",
|
||||
"-s",
|
||||
"-r",
|
||||
"1",
|
||||
"1", // This ensures only the latest release is considered for generation
|
||||
],
|
||||
{ stdio: "inherit", shell: true }
|
||||
);
|
||||
@@ -66,24 +66,58 @@ if (result.status !== 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const getLatestChangelog = () =>
|
||||
new Promise((resolve, reject) => {
|
||||
const changelogStream = conventionalChangelog({ releaseCount: 1 });
|
||||
// Corrected function to get the latest changelog entry from CHANGELOG.md
|
||||
const getLatestChangelog = async () => {
|
||||
try {
|
||||
const changelogContent = await fs.readFile(
|
||||
path.resolve(__dirname, "../CHANGELOG.md"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
let changelog = "";
|
||||
changelogStream.on("data", (chunk) => {
|
||||
changelog += chunk.toString();
|
||||
});
|
||||
// Regex to capture the content of the latest release.
|
||||
// It looks for a line starting with "## [" (the start of a release heading)
|
||||
// and captures everything until the next "## [" or the end of the file.
|
||||
// The `m` flag makes `^` and `$` match start/end of lines, not just string.
|
||||
// The `s` flag allows `.` to match newlines.
|
||||
const latestEntryMatch = changelogContent.match(
|
||||
/^(## \[.*?\] - .*?\n[\s\S]*?)(?=^## \[|\Z)/m
|
||||
);
|
||||
|
||||
changelogStream.on("end", () => {
|
||||
resolve(changelog);
|
||||
});
|
||||
if (latestEntryMatch && latestEntryMatch[1]) {
|
||||
// Split the matched content into lines
|
||||
const lines = latestEntryMatch[1].split("\n");
|
||||
|
||||
// Find the index of the first non-heading line
|
||||
// The first line is usually the heading (e.g., "## [1.0.0] - 2024-01-01")
|
||||
// So we start checking from the second line (index 1).
|
||||
let firstContentLineIndex = -1;
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
if (lines[i].trim() !== "") {
|
||||
// Check for non-empty and non-whitespace lines
|
||||
firstContentLineIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (firstContentLineIndex !== -1) {
|
||||
// Join the lines from the first content line onwards and trim any leading/trailing whitespace
|
||||
return lines.slice(firstContentLineIndex).join("\n").trim();
|
||||
}
|
||||
return ""; // No content found after heading
|
||||
} else {
|
||||
console.warn(
|
||||
"Could not find the latest changelog entry in CHANGELOG.md. Ensure it's formatted correctly."
|
||||
);
|
||||
return "No changelog notes available."; // Default message if not found
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error reading or parsing CHANGELOG.md:", err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
changelogStream.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
const releaseNotes = await getLatestChangelog();
|
||||
|
||||
// Step 3: Create or update Gitea release
|
||||
const createOrUpdateRelease = async () => {
|
||||
const tagName = `v${version}`;
|
||||
|
||||
Reference in New Issue
Block a user