aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-30 20:48:20 +0800
committerFabio Berger <me@fabioberger.com>2018-03-30 20:48:20 +0800
commit4bc6096ec0415a83446b274f249c57ceb4fe93a3 (patch)
treee95ec9247fe59701d8b175b0c42de7545b33b2df /packages/monorepo-scripts
parent95eb11405156a42ae734ed74945b44a9125d23b3 (diff)
downloaddexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.tar
dexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.tar.gz
dexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.tar.bz2
dexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.tar.lz
dexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.tar.xz
dexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.tar.zst
dexon-sol-tools-4bc6096ec0415a83446b274f249c57ceb4fe93a3.zip
Fetch Github release notes from CHANGELOG.json and update CHANGELOG once they've been successfully published to Github
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}`;