Skip to content

Social Media ​

Announce each release on Twitter (X), Slack and Microsoft Teams with Relizy, with or without AI.

How It Works ​

relizy release posts the release once the provider release is created (see the steps of a release). relizy social posts it on its own (see relizy social).

  • A platform posts only when social.<platform>.enabled is true. release.social (true by default) runs the step in relizy release; --no-social and --canary skip it.
  • A release is announced in one post per platform, even when it ships several versions (see Releases of Several Versions). Teams posts one card per version by default (see Microsoft Teams).
  • With onlyStable (the default of Slack and Teams), the prereleases are not announced.
  • Before the bump, the safety check of relizy release checks the credentials, the dependencies and the AI provider of the enabled platforms: a missing one fails the release before anything is written. --no-safety-check skips it.
  • A failed post does not stop the release: the error is in the logs and in the summary, the social step is in the failed_steps output, and the next steps run.

The options are listed in Social Configuration, the variables of the templates in Template Variables.

Twitter ​

1. Create an X App ​

  1. In the X Developer Portal, create a project and an app.
  2. In the settings of the app, set the permissions to Read and write.
  3. In Keys and tokens, generate the API key and secret, then the access token and secret (generate them after setting the permissions, or they stay read-only).

The X API is paid per use: each tweet consumes credits of your developer account. When they are depleted, X answers 402 and Relizy logs a hint to top them up.

2. Install and Enable ​

bash
pnpm add -D twitter-api-v2
ts
import { defineConfig } from 'relizy'

export default defineConfig({
  social: {
    twitter: {
      enabled: true,
    },
  },
})

3. Set the Credentials ​

Set the four credentials as environment variables (TWITTER_API_KEY, TWITTER_API_KEY_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET, or their RELIZY_ variants), or in tokens.twitter: see Tokens. social.twitter.credentials overrides them field by field.

The Tweet ​

The tweet is social.twitter.template, else templates.twitterMessage:

text
📣 {{releaseTitle}}

{{changelog}}

{{releaseUrl}}
{{changelogUrl}}

The changelog is the one of the release, without its section headings, its commit references and the bold of the scopes, one commit per line. It fills the space the rest of the template leaves within postMaxLength (280 by default), counted as X counts it: a URL counts 23 characters, an emoji or a CJK character counts 2. What does not fit is cut with .... A URL not set (no release URL, no social.changelogUrl) is removed, with its line when it is alone on it. An @ followed by a word (@scope/pkg) gets a zero-width space, so that X does not mention an account.

For a release of my-lib 3.0.0 with two features and a fix:

text
📣 my-lib 3.0.0 is out!

- core: Add streaming API support
- auth: Implement OAuth2 PKCE
- cache: Fix TTL expiration

https://github.com/acme/my-lib/releases/tag/v3.0.0

With AI, the changelog is rewritten as plain text sentences within the same budget (see AI-Written Posts).

Slack ​

Relizy posts to Slack with an Incoming Webhook or with a bot token:

Incoming WebhookBot token
SetupOne URLA Slack app, a scope, an invitation in the channel
ChannelThe one of the webhooksocial.slack.channel
@slack/web-apiNot neededRequired
PriorityUsed when both are configuredIgnored (with a warning) when a webhook is set

Both post the same message.

Option A: Incoming Webhook ​

  1. In Slack API Apps, pick or create an app of your workspace.
  2. In Features → Incoming Webhooks, turn on Activate Incoming Webhooks.
  3. Click Add New Webhook to Workspace, pick the channel, and copy the URL (https://hooks.slack.com/services/...).

Set it in SLACK_WEBHOOK_URL (or RELIZY_SLACK_WEBHOOK_URL, read first), or in social.slack.webhookUrl, then enable Slack:

ts
import { defineConfig } from 'relizy'

export default defineConfig({
  social: {
    slack: {
      enabled: true,
    },
  },
})

A social.slack.channel is ignored in this mode (with a warning): the channel is the one of the webhook.

Option B: Bot Token ​

  1. In Slack API Apps, click Create New App → From scratch.
  2. In OAuth & Permissions → Bot Token Scopes, add chat:write (and chat:write.public to post in a public channel without inviting the bot).
  3. Click Install to Workspace, and copy the Bot User OAuth Token (xoxb-...).
  4. Invite the bot in the channel: /invite @YourBot.
bash
pnpm add -D @slack/web-api
ts
import { defineConfig } from 'relizy'

export default defineConfig({
  social: {
    slack: {
      enabled: true,
      channel: '#releases', // or a channel ID: 'C1234567890'
    },
  },
})

Set the token in SLACK_TOKEN or RELIZY_SLACK_TOKEN, or in tokens.slack (see Tokens). social.slack.credentials.token overrides it.

The Message ​

Without template, the message is made of Slack blocks, in this order:

  1. a header, 📣 {{releaseTitle}};
  2. the changelog, converted from markdown to Slack mrkdwn (bold, links as <url|text>, bullets as •, headings in bold);
  3. 📦 Packages: each released package with its old and new versions, except the packages a section of the changelog already lists (hidden by noPackages);
  4. ❤️ Contributors: the names of the authors of the commits, without bots nor AI tools (hidden by noAuthors, globally or in social.slack.noAuthors);
  5. the buttons 📦 View Release and 📋 Full Changelog, when the release URL and social.changelogUrl are known.

changelog sets how much of the changelog is shown (none or false shows none):

  • summary (default): the commit titles, in one block of at most postMaxLength characters (2500 by default, 3000 at most, the limit of a Slack block). Beyond, the last commits are replaced with an "… and N more changes" line.
  • full: the commit bodies (following changelog.includeCommitBody) and the PR and issue links, as Slack rich text: one block per section, the body paragraphs as quotes, its lists as nested lists, its code as code blocks. Slack rejects a message of more than 50 blocks or about 13,200 characters of rich text: Relizy cuts the changelog at the limit (with …, even inside a commit body) and announces the commits left out with an "… and N more changes" line. Set social.changelogUrl so that Full Changelog links to the rest.
bash
relizy social --slack-format full

With a template (or templates.slackMessage), the message is a single mrkdwn block of at most 3000 characters, written with the mrkdwn syntax of Slack (*bold*, <url|text>):

ts
export default defineConfig({
  social: {
    slack: {
      enabled: true,
      template: '*{{releaseTitle}}*\n\n{{changelog}}\n\n{{packages}}\n\n<{{releaseUrl}}|View the release>',
    },
  },
})

Announcements on Slack ​

announcements chooses the versions of the message, with the same entries as Teams: without it, every version is announced; with it, only the versions matching a { group } or { package } entry. Each entry can set:

  • title, which replaces the name of the version: *Design System* 7.0.0 instead of *Maz UI* 7.0.0, the header for a single version;
  • message, in markdown, under the title;
  • the links 📖 Release notes, 📝 Changelog and links, under the message (the buttons of the message for a single version).

exclude leaves groups and packages out, even when an entry matches them. Twitter has exclude only.

ts
export default defineConfig({
  social: {
    slack: {
      enabled: true,
      announcements: [
        { group: 'ecosystem', title: 'Design System', message: 'Update `@acme/ui` to get it.', links: [{ title: '📚 Docs', url: 'https://design.acme.dev' }] },
        { group: 'shared' },
      ],
      exclude: { packages: ['@acme/*-mock'] },
    },
    twitter: {
      enabled: true,
      exclude: { groups: ['shared'] },
    },
  },
})

Microsoft Teams ​

Relizy posts Adaptive Cards to a Teams workflow (Power Automate). The Office 365 connectors (https://*.webhook.office.com/...) are retired: Relizy refuses their URLs.

1. Create the Workflow ​

  1. In Teams, open the channel, click ⋯ → Workflows, and pick the template Send webhook alerts to a channel (or, in Power Automate, create an instant cloud flow with the trigger When a Teams webhook request is received, then the action Post card in a chat or channel, with the Adaptive card of the attachments).
  2. Pick the team and the channel, then Add workflow.
  3. Copy the URL of the workflow (https://<id>.logic.azure.com/workflows/... or https://<id>.powerplatform.com/...). It holds a secret, the sig parameter: store it as a secret, never in the config.

Check these settings of the trigger and of the flow:

  • Who can trigger the flow: Anyone. The other choices need a Microsoft Entra token, which Relizy does not send: the workflow answers 401 or 403.
  • Owners: the flow runs under the account that created it. When this account leaves the organization or loses its license, the flow stops: add co-owners in Power Automate.
  • Private channel: the Flow bot cannot post there. Post as User in the action of the flow.

2. Enable and Set the URL ​

ts
import { defineConfig } from 'relizy'

export default defineConfig({
  social: {
    teams: {
      enabled: true,
    },
  },
})

Set the URL in TEAMS_WEBHOOK_URL (or RELIZY_TEAMS_WEBHOOK_URL, read first), or in social.teams.webhookUrl. A masked variable of GitLab refuses the characters of the URL (?, &, %): set its base64 in TEAMS_WEBHOOK_URL_B64 (or RELIZY_TEAMS_WEBHOOK_URL_B64) instead.

bash
printf '%s' 'https://<id>.logic.azure.com/workflows/...' | base64

The Card ​

A card announces a version:

  1. a New release badge (Prerelease for a prerelease, set by badge);
  2. the title, {{name}} {{newVersion}} by default, and the message, in markdown;
  3. the version and the date (locale sets its format);
  4. with changelog: 'summary', the titles of the commits, with 'full' the whole changelog, cut between two changes to fit in the card;
  5. the buttons 📖 Release notes (the GitHub/GitLab release of the version) and 📝 Changelog (the CHANGELOG.md of the version at its tag, else social.changelogUrl), then the links.

cards sets how a release is posted:

  • version (default): one card per version, the root version of a unified/selective group and each package of an independent group.
  • release: one card for the release, with a section per version under the title of its group.

Announcements ​

Without announcements, every version is announced with the texts of social.teams. With it, only the versions matching an entry are, each with its own texts:

  • { group: 'name' }: the versions of a version group: its root version, or each of its packages when it is independent.
  • { package: '@scope/nav' }: the packages whose name matches (a glob, @scope/*). Its fields override the ones of its group entry, field by field.

The texts and the links take the variables of the version: {{name}}, {{shortName}} (the name without its scope), {{newVersion}}, {{tag}}, {{groupTitle}}, {{projectName}}, {{releaseUrl}}, {{changelogUrl}} (see Announcement Variables).

ts
export default defineConfig({
  monorepo: {
    groups: [
      { name: 'ecosystem', title: 'Design System', versionMode: 'unified', packages: ['packages/*'] },
      { name: 'shared', title: 'Shared components', versionMode: 'independent', packages: ['shared/*'] },
      { name: 'internal', versionMode: 'independent', packages: ['internal/*'] },
    ],
  },
  social: {
    teams: {
      enabled: true,
      locale: 'fr-FR',
      announcements: [
        {
          group: 'ecosystem',
          title: '🎨 Design System {{newVersion}}',
          message: 'A new version of the **Design System** is available.',
          changelogUrl: 'https://design.acme.dev/changelog',
          links: [{ title: '📚 Docs', url: 'https://design.acme.dev' }],
        },
        {
          group: 'shared',
          message: 'A new version of **{{name}}** is available.',
          links: [{ title: '🎨 Storybook', url: 'https://{{shortName}}.acme.dev' }],
        },
        { package: '@acme/login', title: '🔐 Login {{newVersion}}' },
      ],
      exclude: { packages: ['@acme/*-mock'] },
    },
  },
})

The internal group has no entry: it is not announced. exclude leaves out groups and packages even when an entry matches them, and a group with release: { social: false } is left out of every platform.

Limits of Teams ​

  • A card is at most 28 KB: its changelogs share what its other texts leave, each one cut between two changes with an … and N more changes line. Relizy refuses a card still bigger (its texts alone) before posting it.
  • A workflow accepts about 4 requests per second: the cards are posted one after the other, and a 429 is tried again.
  • A card renders basic markdown only (bold, italic, links, lists): the headings of the changelog become bold lines, the HTML and the code blocks are removed.
  • The workflow answers 202 as soon as it receives the card: when the card does not show up, open the run history of the flow in Power Automate.

Releases of Several Versions ​

A release ships several versions with version groups, or several packages of an independent release. It is announced once per platform: {{releaseTitle}} is New releases of <projectName> and {{newVersion}} is empty, then the changelog has a section per group, the unified/selective group first. Each section is titled with the title of its group (<title> <version> for a unified/selective group), and lists the packages of an independent group with their versions.

Twitter: the tweet is filled by priority, so that it never exceeds postMaxLength:

  1. the version line of every section. When the packages of an independent group do not fit, the group is collapsed to <title>: N packages, the last groups first;
  2. the highlights of the changes, the first sections first: the bullets of a unified/selective group, the first change of each package of an independent group.

An independent release of two packages, without version groups:

text
📣 New releases of acme

• @acme/core 1.3.0: Add streaming API support
• @acme/cli 0.4.1: Fix the exit code of the init command

Slack: the changelog has a block per section (summary), or its title and rich text blocks (full): each package of an independent group with its old and new versions, then its changelog. The budget of the message (postMaxLength, the 3000 characters of a block, the 50 blocks and the size of the payload) is shared between the sections: each one gets what it needs within an equal share, what the small ones leave goes to the others, and each one keeps at least its title and its version lines. The contributors of every group are listed once.

With onlyStable, the prereleases are left out of the post, and nothing is posted when every version is a prerelease. The announcements and exclude of a platform leave out the versions it does not announce. A version group with release: { social: false } is left out of the posts. See One Release, Presented by Group for a release of several groups.

AI-Written Posts ​

With ai.social, the AI rewrites the changelog of each enabled platform: plain sentences for Twitter, standard markdown for Slack (converted to mrkdwn by Relizy), short bullets for the Teams cards (with changelog: 'summary'). The titles, the versions and the links stay as Relizy computes them. A release of several versions is rewritten in one call per platform. Setup, preview in dry run and tuning: AI-Enhanced Changelogs.

ts
export default defineConfig({
  ai: {
    social: {
      twitter: { enabled: true },
      slack: { enabled: true },
      teams: { enabled: true },
    },
  },
})

Hooks ​

The hooks before:social, success:social, error:social run around the posts, and before:twitter, success:twitter, error:twitter, before:slack, success:slack, error:slack, before:teams, success:teams, error:teams around each platform, once per release. A function hook gets the release as third parameter when it is known (in relizy release): its release lists the packages and versions by group, in the platform hooks what the post announces (without the prereleases left out by onlyStable).

ts
export default defineConfig({
  hooks: {
    'success:slack': (config, dryRun, context) => {
      const packages = context?.release.groups.flatMap(group => group.packages) ?? []
      console.log(`Announced ${packages.length} packages on Slack`)
    },
  },
})

See Hooks.

In CI ​

Pass the credentials as secrets of the job running the release, under the environment variables of Tokens. Complete workflows: GitHub Actions, GitLab CI.

The relizy action has an input per token, and passes the other variables of the step:

yaml
- uses: relizy/action@v2
  with:
    twitter-api-key: ${{ secrets.TWITTER_API_KEY }}
    twitter-api-key-secret: ${{ secrets.TWITTER_API_KEY_SECRET }}
    twitter-access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
    twitter-access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
    teams-webhook-url: ${{ secrets.TEAMS_WEBHOOK_URL }}
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

On GitLab CI, the CI/CD variables reach the relizy component under their names: nothing to pass.

On GitLab, create the CI/CD variables with these names (masked), and TEAMS_WEBHOOK_URL_B64 for Teams.

Troubleshooting ​

ErrorFix
Twitter credentials not foundSet the four Twitter credentials: the missing ones are listed above the error
twitter-api-v2 is not installedpnpm add -D twitter-api-v2
403 from XThe app is not Read and write, or the access token was generated before: regenerate it
402 from XThe credits of the X developer account are depleted
Slack credentials not foundSet a webhook URL, or a token and social.slack.channel
Slack channel not found (token)Set social.slack.channel, with its #, or its ID
@slack/web-api is not installed (token)pnpm add -D @slack/web-api, or use a webhook
Bot is not in the channel (token)/invite @YourBot in the channel
Missing required OAuth scope (token)Add chat:write to the bot token scopes, reinstall the app, use the new token
Slack webhook failed: 404The webhook URL is invalid or deactivated: create a new one
Slack webhook failed with invalid_payloadThe message exceeds the limits of Slack: lower postMaxLength, or shorten the template
Teams webhook URL not foundSet TEAMS_WEBHOOK_URL (or TEAMS_WEBHOOK_URL_B64), or social.teams.webhookUrl
URL of an Office 365 connectorThe connectors are retired: create a Teams workflow and use its URL
Teams workflow failed: 401 or 403Set Who can trigger the flow to Anyone, and keep the sig parameter of the URL
Teams workflow failed: 404The flow was deleted, turned off, or its owner left: create it again, add co-owners
Teams workflow failed: 400, or over 28 KBThe card is too big: use cards: 'version', or changelog: 'none'

To check a post without publishing it, run relizy social --dry-run: it shows the tweet with its length, the Slack message and the Teams cards (--log-level verbose prints their JSON).

See Also ​