diff --git a/tools/continuous-delivery/src/sendMessageAboutRelease.ts b/tools/continuous-delivery/src/sendMessageAboutRelease.ts index e0b8cf505f..3b5db0612b 100644 --- a/tools/continuous-delivery/src/sendMessageAboutRelease.ts +++ b/tools/continuous-delivery/src/sendMessageAboutRelease.ts @@ -6,7 +6,7 @@ export async function sendMessageAboutRelease(version: string, lastVersionChange log('Sending message to internal Slack...'); try { - const title = `New release ${version} is here!`; + const title = `:whale2: Semcore Release v${version.replace(/^v/, '')}`; const body = makeMessageFromChangelogs(lastVersionChangelogs, false); await sendMessage({ diff --git a/tools/continuous-delivery/src/utils/slackIntegration.ts b/tools/continuous-delivery/src/utils/slackIntegration.ts index 38293836a5..8364a58365 100644 --- a/tools/continuous-delivery/src/utils/slackIntegration.ts +++ b/tools/continuous-delivery/src/utils/slackIntegration.ts @@ -3,18 +3,28 @@ import axios from 'axios'; import type { ChangelogChangeLabel, ChangelogItem } from './changelog'; const type2SectionLabel: Record = { - added: ':white_check_mark: ADDED', - changed: ':recycle: CHANGED', - fixed: ':hammer_and_wrench: FIXED', - removed: ':wastebasket: REMOVED', - break: ':interrobang: BREAK', + added: ':sparkles: Added', + changed: ':arrows_counterclockwise: Changed', + fixed: ':ladybug: Fixed', + removed: ':wastebasket: Removed', + break: ':warning: Break', }; export const makeMessageFromChangelogs = (changelogs: ChangelogItem[], withVersions: boolean) => changelogs.map((item) => bodyTemplate(item, withVersions)).join('\n'); -const titleTemplate = (name: string, version: string | null) => - `\n-------- \n:black_heart: *${name}* ${version ? `v${version}` : ''} \n\n`; +const formatComponentDisplayName = (component: string): string => { + const name = component.replace(/^@semcore\//i, ''); + + if (!name) { + return component; + } + + return name.charAt(0).toUpperCase() + name.slice(1); +}; + +const getSectionTitle = (label: string): string => + type2SectionLabel[label.toLowerCase()] ?? label.toUpperCase(); const bodyTemplate = (changeItem: ChangelogItem, withVersions: boolean) => { const sections: Partial<{ [label in NonNullable]: string[] }> = {}; @@ -25,20 +35,19 @@ const bodyTemplate = (changeItem: ChangelogItem, withVersions: boolean) => { } } - return ( - titleTemplate(changeItem.component, withVersions ? changeItem.version : null) + - Object.entries(sections) - .map(([label, changeDescriptions]) => { - const title = label in type2SectionLabel ? type2SectionLabel[label] : label.toUpperCase(); - - return ( - title + - '\n' + - changeDescriptions.map((changeDescription) => `- ${changeDescription}`).join('\n') - ); - }) - .join('\n') - ); + const versionSuffix = + withVersions && changeItem.version ? ` v${changeItem.version}` : ''; + const header = `- - -\n*${formatComponentDisplayName(changeItem.component)}*${versionSuffix}`; + const sectionsText = Object.entries(sections) + .map(([label, changeDescriptions]) => { + const title = getSectionTitle(label); + const lines = changeDescriptions.join('\n'); + + return lines ? `${title}\n${lines}` : title; + }) + .join('\n'); + + return sectionsText ? `${header}\n${sectionsText}` : header; }; export const sendMessage = async ({