Skip to content

Commit

Permalink
fixup! Feat(ci): Introduce posting changelog into the Slack channel
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Dec 16, 2024
1 parent 3c424ba commit eb2b671
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions scripts/post-changelog.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/* eslint-disable no-console */
import { $, fetch, argv } from 'zx';
import dotenv from 'dotenv-safe';
import slackifyMarkdown from 'slackify-markdown';
import { simpleGit } from 'simple-git';
import gitDiffParser from 'gitdiff-parser';

/* eslint-disable no-console */

const CHANNEL = '#spirit-design-system-notifications_en';
const COLOR_CORE = '#00A58E';
const PACKAGES = [/* 'web', */ 'web-react' /* 'design-tokens', 'icons', 'codemods', 'analytics' */];
const PACKAGES = ['web', 'web-react', 'design-tokens', 'icons', 'codemods', 'analytics'];
const SLACK_CHANGELOG_WEBHOOK_URL = process.env.SLACK_CHANGELOG_WEBHOOK_URL ?? '';

function getTitle(pkg) {
Expand Down Expand Up @@ -120,10 +118,7 @@ async function publishChangelog(package_) {
await simpleGit().fetch(['origin', 'main', '--tags']);
const tags = await simpleGit().tags({ '--sort': '-taggerdate' });
console.log(tags.latest);
const diff = await getDiff(
'@lmc-eu/[email protected]' /* tags.latest */ ?? '',
changelogPath(package_),
);
const diff = await getDiff(tags.latest ?? '', changelogPath(package_));
const files = gitDiffParser.parse(diff);
if (files.length === 0) {
console.log(`No changes in ${package_}`);
Expand All @@ -134,7 +129,7 @@ async function publishChangelog(package_) {
const formattedChangelog = format(changelog, package_);
const slackifiedChangelog = slackifyMarkdown(formattedChangelog);

if (false /* argv.dry */) {
if (argv.dry) {
console.info(formattedChangelog);
} else {
await configureWebhookURL();
Expand Down

0 comments on commit eb2b671

Please sign in to comment.