- replace ENV variable output with normal output (requires re-passing)

- update README
This commit is contained in:
Mike Penz
2023-06-04 10:20:31 +00:00
committed by GitHub
parent 91da901770
commit 5dd6b400c7
8 changed files with 54 additions and 82 deletions
-2
View File
@@ -54,7 +54,6 @@ async function run(): Promise<void> {
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true'
const fetchReviews = core.getInput('fetchReviews') === 'true'
const commitMode = core.getInput('commitMode') === 'true'
const exportCollected = core.getInput('exportCollected') === 'true'
const exportOnly = core.getInput('exportOnly') === 'true'
const result = await new ReleaseNotesBuilder(
@@ -72,7 +71,6 @@ async function run(): Promise<void> {
fetchReleaseInformation,
fetchReviews,
commitMode,
exportCollected,
exportOnly,
configuration
).build()
+15 -30
View File
@@ -27,6 +27,7 @@ export interface Data {
mergedPullRequests: PullRequestInfo[]
options: ReleaseNotesOptions
}
export class ReleaseNotesBuilder {
constructor(
private baseUrl: string | null,
@@ -43,13 +44,12 @@ export class ReleaseNotesBuilder {
private fetchReleaseInformation: boolean = false,
private fetchReviews: boolean = false,
private commitMode: boolean = false,
private exportCollected: boolean = false,
private exportOnly: boolean = false,
private configuration: Configuration
) {}
async build(): Promise<string | null> {
let releaseNotesData = checkExportedData()
const releaseNotesData = checkExportedData()
if (releaseNotesData == null) {
if (!this.owner) {
failOrError(`💥 Missing or couldn't resolve 'owner'`, this.failOnError)
@@ -121,28 +121,23 @@ export class ReleaseNotesBuilder {
core.setOutput('changes', diffInfo.changes)
core.setOutput('commits', diffInfo.commits)
if (this.exportCollected) {
core.info('📦 Exporting collected data')
core.exportVariable(`RCBA_EXPORT_diffInfo`, JSON.stringify(diffInfo))
//fs.writeFileSync(path.resolve('diffInfo.json'), JSON.stringify(diffInfo))
core.exportVariable(`RCBA_EXPORT_mergedPullRequests`, JSON.stringify(mergedPullRequests))
//fs.writeFileSync(path.resolve('mergedPullRequests.json'), JSON.stringify(mergedPullRequests))
core.exportVariable(`RCBA_EXPORT_options`, JSON.stringify(options))
//fs.writeFileSync(path.resolve('options.json'), JSON.stringify(options))
if (this.exportOnly) {
core.endGroup()
return null
}
}
releaseNotesData = {
const cache = {
mergedPullRequests,
diffInfo,
options
}
core.setOutput(`cache`, JSON.stringify(cache))
//fs.writeFileSync(path.resolve('cache.json'), JSON.stringify(cache))
if (this.exportOnly) {
core.info(`️ Enabled 'exportOnly' will not generate changelog`)
core.endGroup()
return null
}
return buildChangelog(diffInfo, mergedPullRequests, options)
} else {
core.info(`️ Retrieved previously exported collected data`)
core.info(`️ Retrieved previously cache data`)
// merge input with options (in case some data was updated)
const diffInfo = releaseNotesData.diffInfo
@@ -173,17 +168,7 @@ export class ReleaseNotesBuilder {
commitMode: this.commitMode || orgOptions.commitMode,
configuration: this.configuration || orgOptions.configuration
}
releaseNotesData = {
diffInfo,
mergedPullRequests,
options
}
}
if (releaseNotesData != null) {
return buildChangelog(releaseNotesData.diffInfo, releaseNotesData.mergedPullRequests, releaseNotesData.options)
} else {
return null
return buildChangelog(diffInfo, mergedPullRequests, options)
}
}
}
+6 -7
View File
@@ -28,13 +28,12 @@ export function retrieveRepositoryPath(providedPath: string): string {
* If available, return a [ReleaseNotesData].
*/
export function checkExportedData(): Data | null {
const rawDiffInfo = process.env[`RCBA_EXPORT_diffInfo`]
const rawMergedPullRequests = process.env[`RCBA_EXPORT_mergedPullRequests`]
const rawOptions = process.env[`RCBA_EXPORT_options`]
const rawCache = core.getInput(`cache`)
if (rawDiffInfo && rawMergedPullRequests && rawOptions) {
const diffInfo: DiffInfo = JSON.parse(rawDiffInfo)
const mergedPullRequests: PullRequestInfo[] = JSON.parse(rawMergedPullRequests)
if (rawCache) {
const cache: Data = JSON.parse(rawCache)
const diffInfo: DiffInfo = cache.diffInfo
const mergedPullRequests: PullRequestInfo[] = cache.mergedPullRequests
for (const pr of mergedPullRequests) {
pr.createdAt = moment(pr.createdAt)
@@ -51,7 +50,7 @@ export function checkExportedData(): Data | null {
}
}
const options: ReleaseNotesOptions = JSON.parse(rawOptions)
const options: ReleaseNotesOptions = cache.options
return {
diffInfo,
mergedPullRequests,