aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r--packages/monorepo-scripts/src/postpublish_utils.ts36
1 files changed, 34 insertions, 2 deletions
diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts
index c4f3135a5..fb1680afd 100644
--- a/packages/monorepo-scripts/src/postpublish_utils.ts
+++ b/packages/monorepo-scripts/src/postpublish_utils.ts
@@ -1,9 +1,12 @@
import { execAsync } from 'async-child-process';
import * as promisify from 'es6-promisify';
+import * as fs from 'fs';
import * as _ from 'lodash';
+import * as path from 'path';
import * as publishRelease from 'publish-release';
import semverSort = require('semver-sort');
+import { constants } from './constants';
import { utils } from './utils';
const publishReleaseAsync = promisify(publishRelease);
@@ -88,23 +91,52 @@ export const postpublishUtils = {
);
},
async publishReleaseNotesAsync(cwd: string, packageName: string, version: string, assets: string[]): Promise<void> {
+ const notes = this.getReleaseNotes(packageName);
const releaseName = this.getReleaseName(packageName, version);
const tag = this.getTag(packageName, version);
- utils.log('POSTPUBLISH: Releasing ', releaseName, '...');
const finalAssets = this.adjustAssetPaths(cwd, assets);
+ utils.log('POSTPUBLISH: Releasing ', releaseName, '...');
const result = await publishReleaseAsync({
token: githubPersonalAccessToken,
owner: '0xProject',
repo: '0x-monorepo',
tag,
name: releaseName,
- notes: 'N/A',
+ notes,
draft: false,
prerelease: false,
reuseRelease: true,
reuseDraftOnly: false,
assets,
});
+ this.updateChangelogIsPublished(packageName);
+ },
+ getReleaseNotes(packageName: string) {
+ const changelogJSONPath = path.join(constants.monorepoRootPath, 'packages', packageName, 'CHANGELOG.json');
+ const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8');
+ const changelogs = JSON.parse(changelogJSON);
+ const latestLog = changelogs[0];
+ if (_.isUndefined(latestLog.isPublished)) {
+ let notes = '';
+ _.each(latestLog.changes, change => {
+ notes = `* ${change.note}`;
+ if (change.pr) {
+ notes += ` (${change.pr})`;
+ }
+ notes += `\n`;
+ });
+ return notes;
+ }
+ return 'N/A';
+ },
+ updateChangelogIsPublished(packageName: string) {
+ const changelogJSONPath = path.join(constants.monorepoRootPath, 'packages', packageName, 'CHANGELOG.json');
+ const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8');
+ const changelogs = JSON.parse(changelogJSON);
+ const latestLog = changelogs[0];
+ latestLog.isPublished = true;
+ changelogs[0] = latestLog;
+ fs.writeFileSync(changelogJSONPath, JSON.stringify(changelogs, null, '\t'));
},
getTag(packageName: string, version: string) {
return `${packageName}@${version}`;