Skip to content

Commit

Permalink
feat: add 'Full Changelog' links in releases description (#21)
Browse files Browse the repository at this point in the history
* chore: bump deps

* bump deps

* feat: add 'Full Changelog' links in releases description

* fix first commit
  • Loading branch information
sylc committed Feb 8, 2023
1 parent c1aa5d0 commit 0897bac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion plugins/changelog/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ const plugin: ReleasePlugin = {

for (let i = 0; i < tags.length; i++) {
const tag = tags[i];
const parent = i < tags.length - 1 ? tags[i + 1] : undefined;
const belonging = commits.filter((_) => _.belongs?.hash === tag.hash);
const filteredTypes = filters.map((f) => f.type);
const filteredCommits = belonging.filter((_) =>
filteredTypes.includes(_.cc.type || "")
);
if (filteredCommits.length) {
pushTag(doc, repo, belonging, filters, tag, "md");
pushTag(doc, repo, belonging, filters, tag, "md", parent);
}
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/github/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const plugin: ReleasePlugin<GithubConfig> = {

const latest = tags[0];
const belonging = commits.filter((_) => _.belongs?.hash === latest.hash);
pushTag(doc, repo, belonging, filters, latest, "github");
const parent = tags.length > 0 ? tags[1] : undefined;
pushTag(doc, repo, belonging, filters, latest, "github", parent);

if (!config.options.dry) {
const token = Deno.env.get(GITHUB_TOKEN)!;
Expand Down
15 changes: 13 additions & 2 deletions src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ export function pushTag(
if (repo.remote && repo.remote.github && style === "md") {
const { user, name } = repo.remote.github;
let url = `https://github.com/${user}/${name}/`;

url = parent
? `${url}compare/${parent.version}...${tag.version}`
: `${url}compare/${tag.version}`;
: `${url}compare/${repo.commits.pop()?.hash}...${tag.version}`;
doc.links.push(fmtLink(tag.version, url));
doc.sections.push(`## [${tag.version}] - ${year}-${month}-${day}`);
} else {
Expand All @@ -107,6 +106,14 @@ export function pushTag(
pushChanges(doc, repo, filter.title, filtered, style);
}
}
if (repo.remote && repo.remote.github && parent) {
const linkName = `${parent.version}...${tag.version}`;
doc.sections.push(`Full Changelog: [${linkName}]`);
const { user, name } = repo.remote.github;
const url =
`https://github.com/${user}/${name}/compare/${parent.version}...${tag.version}`;
doc.links.push(fmtLink(linkName, url));
}
}

export function render(doc: Document): string {
Expand All @@ -116,6 +123,10 @@ export function render(doc: Document): string {
return `${full.join("\n\n").trim()}\n`;
}

/**
* Add the new tag to the list of tags. beeing the latest it is the first one
* @returns array of tags and commits
*/
export function polyfillVersion(repo: Repo, to: string): [Tag[], Commit[]] {
const newtag: Tag = {
tag: to,
Expand Down

0 comments on commit 0897bac

Please sign in to comment.