aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2019-01-10 18:51:13 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2019-01-10 18:56:15 +0800
commitcee29542451d3bf8c99bd08963a2108768072195 (patch)
treef3d657be53459ce3851fcf9632bd94f32ee80184 /packages/monorepo-scripts/src
parenta8d9263062e586b90ee4c303d3d3aca72e428edc (diff)
parent686f27a96f0cd749f6315d7edd2bb56cf1819245 (diff)
downloaddexon-0x-contracts-cee29542451d3bf8c99bd08963a2108768072195.tar.gz
dexon-0x-contracts-cee29542451d3bf8c99bd08963a2108768072195.tar.zst
dexon-0x-contracts-cee29542451d3bf8c99bd08963a2108768072195.zip
Merge development
Diffstat (limited to 'packages/monorepo-scripts/src')
-rw-r--r--packages/monorepo-scripts/src/constants.ts2
-rw-r--r--packages/monorepo-scripts/src/doc_gen_configs.ts1
-rw-r--r--packages/monorepo-scripts/src/prepublish_checks.ts7
-rw-r--r--packages/monorepo-scripts/src/publish.ts12
-rw-r--r--packages/monorepo-scripts/src/utils/discord.ts26
-rw-r--r--packages/monorepo-scripts/src/utils/github_release_utils.ts7
6 files changed, 53 insertions, 2 deletions
diff --git a/packages/monorepo-scripts/src/constants.ts b/packages/monorepo-scripts/src/constants.ts
index acb4b211e..c15bcabf4 100644
--- a/packages/monorepo-scripts/src/constants.ts
+++ b/packages/monorepo-scripts/src/constants.ts
@@ -5,5 +5,7 @@ export const constants = {
stagingWebsite: 'http://staging-0xproject.s3-website-us-east-1.amazonaws.com',
lernaExecutable: path.join('node_modules', '@0x-lerna-fork', 'lerna', 'cli.js'),
githubPersonalAccessToken: process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS,
+ discordAlertWebhookUrl: process.env.DISCORD_GITHUB_RELEASE_WEBHOOK_URL,
+ releasesUrl: 'https://github.com/0xProject/0x-monorepo/releases',
dependenciesUpdatedMessage: 'Dependencies updated',
};
diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts
index dfbe98028..7a4e6bb2c 100644
--- a/packages/monorepo-scripts/src/doc_gen_configs.ts
+++ b/packages/monorepo-scripts/src/doc_gen_configs.ts
@@ -9,6 +9,7 @@ export const docGenConfigs: DocGenConfigs = {
Array: 'https://developer.mozilla.org/pt-PT/docs/Web/JavaScript/Reference/Global_Objects/Array',
BigNumber: 'http://mikemcl.github.io/bignumber.js',
Error: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error',
+ ErrorConstructor: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error',
Buffer: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v9/index.d.ts#L262',
'solc.StandardContractOutput':
'https://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#output-description',
diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts
index 36e61714b..82eaf5cf9 100644
--- a/packages/monorepo-scripts/src/prepublish_checks.ts
+++ b/packages/monorepo-scripts/src/prepublish_checks.ts
@@ -140,6 +140,13 @@ async function checkPublishRequiredSetupAsync(): Promise<void> {
);
}
+ // Check to see if discord URL is set up
+ if (_.isUndefined(constants.discordAlertWebhookUrl)) {
+ throw new Error(
+ 'You must have a discord webhook URL set to an envVar named `DISCORD_GITHUB_RELEASE_WEBHOOK_URL`. Add it then try again.',
+ );
+ }
+
// Check Yarn version is 1.X
utils.log('Checking the yarn version...');
const result = await execAsync(`yarn --version`);
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts
index 854a72b86..e0602a74f 100644
--- a/packages/monorepo-scripts/src/publish.ts
+++ b/packages/monorepo-scripts/src/publish.ts
@@ -14,6 +14,7 @@ import { constants } from './constants';
import { Package, PackageToNextVersion, VersionChangelog } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { configs } from './utils/configs';
+import { alertDiscordAsync } from './utils/discord';
import { DocGenerateAndUploadUtils } from './utils/doc_generate_and_upload_utils';
import { publishReleaseNotesAsync } from './utils/github_release_utils';
import { utils } from './utils/utils';
@@ -84,7 +85,16 @@ async function confirmAsync(message: string): Promise<void> {
await generateAndUploadDocJsonsAsync(packagesWithDocs, isStaging, shouldUploadDocs);
}
const isDryRun = configs.IS_LOCAL_PUBLISH;
- await publishReleaseNotesAsync(updatedPublicPackages, isDryRun);
+ const releaseNotes = await publishReleaseNotesAsync(updatedPublicPackages, isDryRun);
+ utils.log('Published release notes');
+
+ if (!isDryRun && releaseNotes) {
+ try {
+ await alertDiscordAsync(releaseNotes);
+ } catch (e) {
+ utils.log("Publish successful, but couldn't auto-alert discord (", e.message, '), Please alert manually.');
+ }
+ }
})().catch(err => {
utils.log(err);
process.exit(1);
diff --git a/packages/monorepo-scripts/src/utils/discord.ts b/packages/monorepo-scripts/src/utils/discord.ts
new file mode 100644
index 000000000..3a0458769
--- /dev/null
+++ b/packages/monorepo-scripts/src/utils/discord.ts
@@ -0,0 +1,26 @@
+import { fetchAsync } from '@0x/utils';
+
+import { constants } from '../constants';
+
+import { utils } from './utils';
+
+export const alertDiscordAsync = async (releaseNotes: string): Promise<void> => {
+ const webhookUrl = constants.discordAlertWebhookUrl;
+ if (webhookUrl === undefined) {
+ throw new Error("No discord webhook url, can't alert");
+ }
+
+ utils.log('Alerting discord...');
+ const payload = {
+ content: `New monorepo package released! View at ${constants.releasesUrl} \n\n ${releaseNotes}`,
+ };
+ await fetchAsync(webhookUrl, {
+ method: 'POST',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(payload),
+ });
+ return;
+};
diff --git a/packages/monorepo-scripts/src/utils/github_release_utils.ts b/packages/monorepo-scripts/src/utils/github_release_utils.ts
index e63244b46..48704f3aa 100644
--- a/packages/monorepo-scripts/src/utils/github_release_utils.ts
+++ b/packages/monorepo-scripts/src/utils/github_release_utils.ts
@@ -12,7 +12,10 @@ import { utils } from './utils';
const publishReleaseAsync = promisify(publishRelease);
// tslint:disable-next-line:completed-docs
-export async function publishReleaseNotesAsync(packagesToPublish: Package[], isDryRun: boolean): Promise<void> {
+export async function publishReleaseNotesAsync(
+ packagesToPublish: Package[],
+ isDryRun: boolean,
+): Promise<string | undefined> {
// Git push a tag representing this publish (publish-{commit-hash}) (truncate hash)
const result = await execAsync('git log -n 1 --pretty=format:"%H"', { cwd: constants.monorepoRootPath });
const latestGitCommit = result.stdout;
@@ -75,6 +78,8 @@ export async function publishReleaseNotesAsync(packagesToPublish: Package[], isD
utils.log('Publishing release notes ', releaseName, '...');
await publishReleaseAsync(publishReleaseConfigs);
+
+ return aggregateNotes;
}
// Asset paths should described from the monorepo root. This method prefixes