+11
-1
@@ -27,7 +27,17 @@ inputs:
|
||||
description: 'Defines the token to use to execute the git API requests with, uses `env.GITHUB_TOKEN` by default'
|
||||
outputs:
|
||||
changelog:
|
||||
description: Returns the generated changelog as markdown.
|
||||
description: The built release changelog built from the merged pull requests
|
||||
owner:
|
||||
description: Specifies the owner of the repository processed
|
||||
repo:
|
||||
description: Describes the repository name, which was processed
|
||||
fromTag:
|
||||
description: Defines the `fromTag` which describes the lower bound to process pull requests for
|
||||
toTag:
|
||||
description: Defines the `toTag` which describes the upper bound to process pull request for
|
||||
failed:
|
||||
description: Defines if there was an issue with the action run, and the changelog may not have been generated correctly. [true, false]
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
{
|
||||
"title": "## 💬 Other",
|
||||
"labels": ["other"]
|
||||
},
|
||||
{
|
||||
"title": "## 📦 Dependencies",
|
||||
"labels": ["dependencies"]
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
-34
@@ -401,6 +401,7 @@ class PullRequests {
|
||||
title: pr.data.title,
|
||||
htmlURL: pr.data.html_url,
|
||||
mergedAt: moment_1.default(pr.data.merged_at),
|
||||
mergeCommitSha: pr.data.merge_commit_sha,
|
||||
author: pr.data.user.login,
|
||||
repoName: pr.data.base.repo.full_name,
|
||||
labels: pr.data.labels.map(function (label) {
|
||||
@@ -444,6 +445,7 @@ class PullRequests {
|
||||
title: pr.title,
|
||||
htmlURL: pr.html_url,
|
||||
mergedAt: moment_1.default(pr.merged_at),
|
||||
mergeCommitSha: pr.merge_commit_sha,
|
||||
author: pr.user.login,
|
||||
repoName: pr.base.repo.full_name,
|
||||
labels: (_b = pr.labels) === null || _b === void 0 ? void 0 : _b.map(function (label) {
|
||||
@@ -480,8 +482,10 @@ class PullRequests {
|
||||
return sortPullRequests(mergedPRs, true);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Filters out all commits which match the exclude pattern
|
||||
*/
|
||||
filterCommits(commits, excludeMergeBranches) {
|
||||
const prRegex = /Merge pull request #(\d+)/;
|
||||
const filteredCommits = [];
|
||||
for (const commit of commits) {
|
||||
if (excludeMergeBranches) {
|
||||
@@ -496,11 +500,6 @@ class PullRequests {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const match = commit.summary.match(prRegex);
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
commit.prNumber = Number.parseInt(match[1], 10);
|
||||
filteredCommits.push(commit);
|
||||
}
|
||||
return filteredCommits;
|
||||
@@ -633,34 +632,15 @@ class ReleaseNotes {
|
||||
core.info(`ℹ️ Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`);
|
||||
const prCommits = pullRequestsApi.filterCommits(commits, configuration.exclude_merge_branches ||
|
||||
configuration_1.DefaultConfiguration.exclude_merge_branches);
|
||||
core.info(`ℹ️ Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`);
|
||||
const filteredPullRequests = [];
|
||||
const pullRequestsByNumber = {};
|
||||
for (const pr of pullRequests) {
|
||||
pullRequestsByNumber[pr.number] = pr;
|
||||
}
|
||||
for (const commit of prCommits) {
|
||||
if (!commit.prNumber) {
|
||||
continue;
|
||||
}
|
||||
const prRef = `${owner}/${repo}#${commit.prNumber}`;
|
||||
if (pullRequestsByNumber[commit.prNumber]) {
|
||||
filteredPullRequests.push(pullRequestsByNumber[commit.prNumber]);
|
||||
}
|
||||
else if (fromDate.toISOString() === toDate.toISOString()) {
|
||||
const pullRequest = yield pullRequestsApi.getSingle(owner, repo, commit.prNumber);
|
||||
if (pullRequest) {
|
||||
filteredPullRequests.push(pullRequest);
|
||||
}
|
||||
else {
|
||||
core.warning(`⚠️ ${prRef} not found! Commit text: ${commit.summary}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.info(`ℹ️ ${prRef} not in date range, excluding from changelog`);
|
||||
}
|
||||
}
|
||||
return filteredPullRequests;
|
||||
core.info(`ℹ️ Retrieved ${prCommits.length} release commits for ${owner}/${repo}`);
|
||||
// create array of commits for this release
|
||||
const releaseCommitHashes = prCommits.map(commmit => {
|
||||
return commmit.sha;
|
||||
});
|
||||
// return only the pull requests associated with this release
|
||||
return pullRequests.filter(pr => {
|
||||
return releaseCommitHashes.includes(pr.mergeCommitSha);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+364
-341
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -41,18 +41,18 @@
|
||||
"semver": "^7.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.14",
|
||||
"@types/node": "^14.11.10",
|
||||
"@typescript-eslint/parser": "^4.5.0",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.6",
|
||||
"@typescript-eslint/parser": "^4.6.0",
|
||||
"@vercel/ncc": "^0.24.1",
|
||||
"eslint": "^7.11.0",
|
||||
"eslint": "^7.12.1",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"eslint-plugin-jest": "^24.1.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^26.6.0",
|
||||
"jest-circus": "^26.6.1",
|
||||
"js-yaml": "^3.14.0",
|
||||
"prettier": "2.1.2",
|
||||
"ts-jest": "^24.3.0",
|
||||
"typescript": "^4.0.3"
|
||||
"typescript": "^4.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ export interface CommitInfo {
|
||||
message: string
|
||||
author: string
|
||||
date: moment.Moment
|
||||
prNumber: number | undefined
|
||||
}
|
||||
|
||||
export class Commits {
|
||||
|
||||
+6
-7
@@ -9,6 +9,7 @@ export interface PullRequestInfo {
|
||||
title: string
|
||||
htmlURL: string
|
||||
mergedAt: moment.Moment
|
||||
mergeCommitSha: string
|
||||
author: string
|
||||
repoName: string
|
||||
labels: string[]
|
||||
@@ -38,6 +39,7 @@ export class PullRequests {
|
||||
title: pr.data.title,
|
||||
htmlURL: pr.data.html_url,
|
||||
mergedAt: moment(pr.data.merged_at),
|
||||
mergeCommitSha: pr.data.merge_commit_sha,
|
||||
author: pr.data.user.login,
|
||||
repoName: pr.data.base.repo.full_name,
|
||||
labels: pr.data.labels.map(function (label) {
|
||||
@@ -88,6 +90,7 @@ export class PullRequests {
|
||||
title: pr.title,
|
||||
htmlURL: pr.html_url,
|
||||
mergedAt: moment(pr.merged_at),
|
||||
mergeCommitSha: pr.merge_commit_sha,
|
||||
author: pr.user.login,
|
||||
repoName: pr.base.repo.full_name,
|
||||
labels: pr.labels?.map(function (label) {
|
||||
@@ -121,11 +124,13 @@ export class PullRequests {
|
||||
return sortPullRequests(mergedPRs, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out all commits which match the exclude pattern
|
||||
*/
|
||||
filterCommits(
|
||||
commits: CommitInfo[],
|
||||
excludeMergeBranches: string[]
|
||||
): CommitInfo[] {
|
||||
const prRegex = /Merge pull request #(\d+)/
|
||||
const filteredCommits = []
|
||||
|
||||
for (const commit of commits) {
|
||||
@@ -141,12 +146,6 @@ export class PullRequests {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const match = commit.summary.match(prRegex)
|
||||
if (!match) {
|
||||
continue
|
||||
}
|
||||
commit.prNumber = Number.parseInt(match[1], 10)
|
||||
filteredCommits.push(commit)
|
||||
}
|
||||
|
||||
|
||||
+9
-34
@@ -107,42 +107,17 @@ export class ReleaseNotes {
|
||||
)
|
||||
|
||||
core.info(
|
||||
`ℹ️ Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`
|
||||
`ℹ️ Retrieved ${prCommits.length} release commits for ${owner}/${repo}`
|
||||
)
|
||||
|
||||
const filteredPullRequests = []
|
||||
const pullRequestsByNumber: {[key: number]: PullRequestInfo} = {}
|
||||
// create array of commits for this release
|
||||
const releaseCommitHashes = prCommits.map(commmit => {
|
||||
return commmit.sha
|
||||
})
|
||||
|
||||
for (const pr of pullRequests) {
|
||||
pullRequestsByNumber[pr.number] = pr
|
||||
}
|
||||
|
||||
for (const commit of prCommits) {
|
||||
if (!commit.prNumber) {
|
||||
continue
|
||||
}
|
||||
|
||||
const prRef = `${owner}/${repo}#${commit.prNumber}`
|
||||
|
||||
if (pullRequestsByNumber[commit.prNumber]) {
|
||||
filteredPullRequests.push(pullRequestsByNumber[commit.prNumber])
|
||||
} else if (fromDate.toISOString() === toDate.toISOString()) {
|
||||
const pullRequest = await pullRequestsApi.getSingle(
|
||||
owner,
|
||||
repo,
|
||||
commit.prNumber
|
||||
)
|
||||
|
||||
if (pullRequest) {
|
||||
filteredPullRequests.push(pullRequest)
|
||||
} else {
|
||||
core.warning(`⚠️ ${prRef} not found! Commit text: ${commit.summary}`)
|
||||
}
|
||||
} else {
|
||||
core.info(`ℹ️ ${prRef} not in date range, excluding from changelog`)
|
||||
}
|
||||
}
|
||||
|
||||
return filteredPullRequests
|
||||
// return only the pull requests associated with this release
|
||||
return pullRequests.filter(pr => {
|
||||
return releaseCommitHashes.includes(pr.mergeCommitSha)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user