- introduce experimental (light) commit based changelog generation mode
- FIX https://github.com/mikepenz/release-changelog-builder-action/issues/141 - this is not fully supported and not documented as it lacks big amounts of the features we know and love - npm install - recompile dist
This commit is contained in:
@@ -33,6 +33,7 @@ async function run(): Promise<void> {
|
||||
// read in flags
|
||||
const ignorePreReleases = core.getInput('ignorePreReleases') === 'true'
|
||||
const failOnError = core.getInput('failOnError') === 'true'
|
||||
const commitMode = core.getInput('commitMode') === 'true'
|
||||
|
||||
const result = await new ReleaseNotesBuilder(
|
||||
token,
|
||||
@@ -43,6 +44,7 @@ async function run(): Promise<void> {
|
||||
toTag,
|
||||
failOnError,
|
||||
ignorePreReleases,
|
||||
commitMode,
|
||||
configuration
|
||||
).build()
|
||||
|
||||
|
||||
+53
-14
@@ -12,6 +12,7 @@ export interface ReleaseNotesOptions {
|
||||
fromTag: string // the tag/ref to start from
|
||||
toTag: string // the tag/ref up to
|
||||
failOnError: boolean // defines if we should fail the action in case of an error
|
||||
commitMode: boolean // defines if we use the alternative commit based mode. note: this is only partially supported
|
||||
configuration: Configuration // the configuration as defined in `configuration.ts`
|
||||
}
|
||||
|
||||
@@ -21,9 +22,17 @@ export class ReleaseNotes {
|
||||
async pull(): Promise<string | null> {
|
||||
const {configuration} = this.options
|
||||
|
||||
core.startGroup(`🚀 Load pull requests`)
|
||||
const mergedPullRequests = await this.getMergedPullRequests(this.octokit)
|
||||
core.endGroup()
|
||||
let mergedPullRequests: PullRequestInfo[]
|
||||
if (!this.options.commitMode) {
|
||||
core.startGroup(`🚀 Load pull requests`)
|
||||
mergedPullRequests = await this.getMergedPullRequests(this.octokit)
|
||||
core.endGroup()
|
||||
} else {
|
||||
core.startGroup(`🚀 Load commit history`)
|
||||
core.info(`⚠️ Executing experimental commit mode`)
|
||||
mergedPullRequests = await this.generateCommitPRs(this.octokit)
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
if (mergedPullRequests.length === 0) {
|
||||
core.warning(`⚠️ No pull requests found`)
|
||||
@@ -40,17 +49,8 @@ export class ReleaseNotes {
|
||||
return resultChangelog
|
||||
}
|
||||
|
||||
private async getMergedPullRequests(
|
||||
octokit: Octokit
|
||||
): Promise<PullRequestInfo[]> {
|
||||
const {
|
||||
owner,
|
||||
repo,
|
||||
fromTag,
|
||||
toTag,
|
||||
failOnError,
|
||||
configuration
|
||||
} = this.options
|
||||
private async getCommitHistory(octokit: Octokit): Promise<CommitInfo[]> {
|
||||
const {owner, repo, fromTag, toTag, failOnError} = this.options
|
||||
core.info(`ℹ️ Comparing ${owner}/${repo} - '${fromTag}...${toTag}'`)
|
||||
|
||||
const commitsApi = new Commits(octokit)
|
||||
@@ -69,6 +69,19 @@ export class ReleaseNotes {
|
||||
return []
|
||||
}
|
||||
|
||||
return commits
|
||||
}
|
||||
|
||||
private async getMergedPullRequests(
|
||||
octokit: Octokit
|
||||
): Promise<PullRequestInfo[]> {
|
||||
const {owner, repo, configuration} = this.options
|
||||
|
||||
const commits = await this.getCommitHistory(octokit)
|
||||
if (commits.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
const firstCommit = commits[0]
|
||||
const lastCommit = commits[commits.length - 1]
|
||||
let fromDate = firstCommit.date
|
||||
@@ -120,4 +133,30 @@ export class ReleaseNotes {
|
||||
return releaseCommitHashes.includes(pr.mergeCommitSha)
|
||||
})
|
||||
}
|
||||
|
||||
private async generateCommitPRs(
|
||||
octokit: Octokit
|
||||
): Promise<PullRequestInfo[]> {
|
||||
const commits = await this.getCommitHistory(octokit)
|
||||
if (commits.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
return commits.map(function (commit) {
|
||||
return {
|
||||
number: 0,
|
||||
title: commit.summary,
|
||||
htmlURL: '',
|
||||
mergedAt: commit.date,
|
||||
mergeCommitSha: '',
|
||||
author: commit.author || '',
|
||||
repoName: '',
|
||||
labels: [],
|
||||
milestone: '',
|
||||
body: commit.message || '',
|
||||
assignees: [],
|
||||
requestedReviewers: []
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export class ReleaseNotesBuilder {
|
||||
private toTag: string | null,
|
||||
private failOnError: boolean,
|
||||
private ignorePreReleases: boolean,
|
||||
private commitMode: boolean,
|
||||
private configuration: Configuration
|
||||
) {}
|
||||
|
||||
@@ -104,6 +105,7 @@ export class ReleaseNotesBuilder {
|
||||
fromTag: this.fromTag,
|
||||
toTag: this.toTag,
|
||||
failOnError: this.failOnError,
|
||||
commitMode: this.commitMode,
|
||||
configuration: this.configuration
|
||||
}
|
||||
const releaseNotes = new ReleaseNotes(octokit, options)
|
||||
|
||||
Reference in New Issue
Block a user