- replace ENV variable output with normal output (requires re-passing)
- update README
This commit is contained in:
@@ -24,6 +24,10 @@ jobs:
|
||||
|
||||
- name: Install NPM
|
||||
run: |
|
||||
cd pr-collector
|
||||
npm run all
|
||||
|
||||
cd ..
|
||||
npm install
|
||||
|
||||
- name: Run NPM
|
||||
@@ -127,7 +131,6 @@ jobs:
|
||||
fromTag: "v8.1.0"
|
||||
toTag: "v8.1.6"
|
||||
token: ${{ secrets.PERSONAL_TOKEN }}
|
||||
exportCollected: true
|
||||
exportOnly: true
|
||||
|
||||
- name: "External Repo Configuration"
|
||||
@@ -137,6 +140,7 @@ jobs:
|
||||
configuration: "configs/configuration_complex.json"
|
||||
owner: "mikepenz"
|
||||
repo: "MaterialDrawer"
|
||||
cache: ${{ steps.external_changelog_collect.outputs.cache }}
|
||||
|
||||
- name: "External Repo Configuration Second"
|
||||
id: external_changelog_second
|
||||
@@ -155,6 +159,7 @@ jobs:
|
||||
}
|
||||
owner: "mikepenz"
|
||||
repo: "MaterialDrawer"
|
||||
cache: ${{ steps.external_changelog_collect.outputs.cache }}
|
||||
|
||||
- name: Echo External Repo Configuration Changelog
|
||||
env:
|
||||
|
||||
@@ -91,6 +91,7 @@ A full set list of possible output values for this action.
|
||||
| `outputs.changes` | Total count of changes in this release (lines). |
|
||||
| `outputs.commits` | Count of commits which have been added in this release. |
|
||||
| `outputs.categorized` | The categorized pull requests used to build the changelog as serialized JSON. |
|
||||
| `outputs.cache` | The cache for the current fetched data. Can be provided to another action step. |
|
||||
|
||||
## Full Sample 🖥️
|
||||
|
||||
@@ -330,6 +331,7 @@ For advanced use cases additional settings can be provided to the action
|
||||
| `fetchReleaseInformation` | Will enable fetching additional release information from tags. Default: false |
|
||||
| `fetchReviews` | Will enable fetching the reviews on of the PR. Default: false |
|
||||
| `commitMode` | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. Default: false |
|
||||
| `cache` | Cached data from a previous run. Will skip fetching PR information |
|
||||
|
||||
> **Warning**: `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
|
||||
|
||||
|
||||
+4
-3
@@ -40,9 +40,6 @@ inputs:
|
||||
commitMode:
|
||||
description: 'Enables a `light` commit based mode. This mode generates changelogs based on the commits. Please note that this is not officially supported, and lacks a lot of features only possible with PRs.'
|
||||
default: "false"
|
||||
exportCollected:
|
||||
description: 'Enables the export of all collected PR information to an environment variable'
|
||||
default: "false"
|
||||
exportOnly:
|
||||
description: 'If enabled, the action will only collect the data and terminate afterwards. Data can then be consumed by steps afterwards'
|
||||
default: "false"
|
||||
@@ -53,6 +50,8 @@ inputs:
|
||||
default: ${{ github.token }}
|
||||
baseUrl:
|
||||
description: 'Defines the base url for GitHub Enterprise authentication, uses `https://api.github.com` by default'
|
||||
cache:
|
||||
description: 'Provide the cache of a previous run. Allows to re-use collected information multiple times to generate different release notes.'
|
||||
outputs:
|
||||
changelog:
|
||||
description: The built release changelog built from the merged pull requests
|
||||
@@ -74,6 +73,8 @@ outputs:
|
||||
description: Count of uncategorized pull requests
|
||||
open_prs:
|
||||
description: Count of open pull requests. Only fetched if `includeOpen` is enabled.
|
||||
cache:
|
||||
description: 'Cache containing this runs data. Allows to re-use collected information multiple times to generate different release notes.'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
||||
+20
-38
@@ -141,9 +141,8 @@ function run() {
|
||||
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 = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchReviewers, fetchReleaseInformation, fetchReviews, commitMode, exportCollected, exportOnly, configuration).build();
|
||||
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchReviewers, fetchReleaseInformation, fetchReviews, commitMode, exportOnly, configuration).build();
|
||||
core.setOutput('changelog', result);
|
||||
// write the result in changelog to file if possible
|
||||
const outputFile = core.getInput('outputFile');
|
||||
@@ -279,7 +278,7 @@ const transform_1 = __nccwpck_require__(1644);
|
||||
const github_pr_collector_1 = __nccwpck_require__(3196);
|
||||
const utils_2 = __nccwpck_require__(853);
|
||||
class ReleaseNotesBuilder {
|
||||
constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode = false, exportCollected = false, exportOnly = false, configuration) {
|
||||
constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode = false, exportOnly = false, configuration) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.token = token;
|
||||
this.repositoryPath = repositoryPath;
|
||||
@@ -294,13 +293,12 @@ class ReleaseNotesBuilder {
|
||||
this.fetchReleaseInformation = fetchReleaseInformation;
|
||||
this.fetchReviews = fetchReviews;
|
||||
this.commitMode = commitMode;
|
||||
this.exportCollected = exportCollected;
|
||||
this.exportOnly = exportOnly;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
build() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let releaseNotesData = (0, utils_1.checkExportedData)();
|
||||
const releaseNotesData = (0, utils_1.checkExportedData)();
|
||||
if (releaseNotesData == null) {
|
||||
if (!this.owner) {
|
||||
(0, utils_2.failOrError)(`💥 Missing or couldn't resolve 'owner'`, this.failOnError);
|
||||
@@ -349,27 +347,22 @@ class ReleaseNotesBuilder {
|
||||
core.setOutput('deletions', diffInfo.deletions);
|
||||
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 (0, transform_1.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;
|
||||
const mergedPullRequests = releaseNotesData.mergedPullRequests;
|
||||
@@ -397,17 +390,7 @@ class ReleaseNotesBuilder {
|
||||
commitMode: this.commitMode || orgOptions.commitMode,
|
||||
configuration: this.configuration || orgOptions.configuration
|
||||
};
|
||||
releaseNotesData = {
|
||||
diffInfo,
|
||||
mergedPullRequests,
|
||||
options
|
||||
};
|
||||
}
|
||||
if (releaseNotesData != null) {
|
||||
return (0, transform_1.buildChangelog)(releaseNotesData.diffInfo, releaseNotesData.mergedPullRequests, releaseNotesData.options);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
return (0, transform_1.buildChangelog)(diffInfo, mergedPullRequests, options);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -951,12 +934,11 @@ exports.retrieveRepositoryPath = retrieveRepositoryPath;
|
||||
* If available, return a [ReleaseNotesData].
|
||||
*/
|
||||
function checkExportedData() {
|
||||
const rawDiffInfo = process.env[`RCBA_EXPORT_diffInfo`];
|
||||
const rawMergedPullRequests = process.env[`RCBA_EXPORT_mergedPullRequests`];
|
||||
const rawOptions = process.env[`RCBA_EXPORT_options`];
|
||||
if (rawDiffInfo && rawMergedPullRequests && rawOptions) {
|
||||
const diffInfo = JSON.parse(rawDiffInfo);
|
||||
const mergedPullRequests = JSON.parse(rawMergedPullRequests);
|
||||
const rawCache = core.getInput(`cache`);
|
||||
if (rawCache) {
|
||||
const cache = JSON.parse(rawCache);
|
||||
const diffInfo = cache.diffInfo;
|
||||
const mergedPullRequests = cache.mergedPullRequests;
|
||||
for (const pr of mergedPullRequests) {
|
||||
pr.createdAt = (0, moment_1.default)(pr.createdAt);
|
||||
if (pr.mergedAt) {
|
||||
@@ -970,7 +952,7 @@ function checkExportedData() {
|
||||
}
|
||||
}
|
||||
}
|
||||
const options = JSON.parse(rawOptions);
|
||||
const options = cache.options;
|
||||
return {
|
||||
diffInfo,
|
||||
mergedPullRequests,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -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
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user