Skip to content

Commit

Permalink
Merge pull request #554 from player-ui/maint/preserve-prerelease-info…
Browse files Browse the repository at this point in the history
…-in-changelogs

Add Changelogs from `next` releases to CHANGELOG.md file
  • Loading branch information
KetanReddy authored Dec 3, 2024
2 parents 1c7b805 + 842c79c commit be1ee3f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .autorc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"labels": "release"
}
],
"./scripts/delete-old-prerelease.js"
"./scripts/delete-old-prerelease.js",
"./scripts/next-changelogs.js"
]
}
34 changes: 34 additions & 0 deletions scripts/next-changelogs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-unused-vars */
/* eslint-disable no-await-in-loop */
const { execSync } = require("child_process");

const getLatestReleaseTag = () => {
const tags = execSync("git tag --sort=-creatordate", { encoding: "utf8" });
return tags
.split("\n")
.map((t) => t.trim())
.filter(
(tag) =>
tag.includes("-next.") ||
tag.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/),
);
};

class NextChangelogsPlugin {
name = "next-changelogs";

apply(auto) {
auto.hooks.next.tapPromise(this.name, async ({ dryRun }) => {
const latestRelease = getLatestReleaseTag();

if (dryRun) {
auto.logger.log.info(`Dry run: making changelog for: ${latestRelease}`);
} else {
await auto.changelog({ from: latestRelease });
}
});
}
}

module.exports = NextChangelogsPlugin;

0 comments on commit be1ee3f

Please sign in to comment.