aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/utils
diff options
context:
space:
mode:
authorSteve Klebanoff <steve@0xproject.com>2019-01-10 08:49:12 +0800
committerGitHub <noreply@github.com>2019-01-10 08:49:12 +0800
commit686f27a96f0cd749f6315d7edd2bb56cf1819245 (patch)
tree47255b7472a582b1a284138a123a1e24612645db /packages/monorepo-scripts/src/utils
parent6487fae1131eb6e9215c918f23bac317157f368b (diff)
parent80f1fe1373e4da161b124d86dd8ec93310b2ea82 (diff)
downloaddexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.tar
dexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.tar.gz
dexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.tar.bz2
dexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.tar.lz
dexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.tar.xz
dexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.tar.zst
dexon-sol-tools-686f27a96f0cd749f6315d7edd2bb56cf1819245.zip
Merge pull request #1482 from 0xProject/feature/monorepo/release-notes
[monorepo-scripts] Automatically alert new release to Discord
Diffstat (limited to 'packages/monorepo-scripts/src/utils')
-rw-r--r--packages/monorepo-scripts/src/utils/discord.ts26
-rw-r--r--packages/monorepo-scripts/src/utils/github_release_utils.ts7
2 files changed, 32 insertions, 1 deletions
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