GuideUpdated

Post release notes to Slack, Discord, LinkedIn and X from CI

One HTTP call posts your release notes to Slack, Discord, your LinkedIn profile and X. Siar, a unified social media API, takes one request from your CI job, sends it to each network, and reports each result, so the job can fail when a network refuses the post. The recipe below uses curl and jq only.

Before you start

  1. In the Siar dashboard, make a brand for the project and connect Slack, Discord, your LinkedIn profile and X to it.
  2. Create an API key and store it as a CI secret named SIAR_API_KEY.
  3. Note the brand's id (GET /api/v1/team/ lists them) and the Slack and Discord channel ids to post to.
  4. Add credit for X. X: open today, billed from a prepaid credit at X's own USD prices. A post that contains a link is $0.200 at X's price.

Slack: open today. Importing replies is slow, because Slack limits apps outside its Marketplace. Discord: open today, posting as a bot with a name and avatar per brand. LinkedIn: personal profiles today; company pages open after LinkedIn grants page access.

The script

Both CI systems run the same POSIX shell script. It builds the request with jq, creates the post, then reads the post until each network has an answer. Each network gets its own text: the notes are trimmed to fit 2,000 characters on Discord and 3,000 on LinkedIn, and X gets the name and link only.

Example: scripts/announce-release.sh
#!/bin/sh
# Example: scripts/announce-release.sh
# Needs: SIAR_API_KEY, SIAR_TEAM_ID, SLACK_CHANNEL, DISCORD_CHANNEL,
#        TAG, NAME, URL, NOTES (set by the CI job below).
set -eu
API="https://api.siaran.my/api/v1"

# jq builds the JSON, so quotes and newlines in the notes are escaped safely.
body=$(jq -n \
  --arg team "$SIAR_TEAM_ID" --arg tag "$TAG" --arg name "$NAME" \
  --arg url "$URL" --arg notes "$NOTES" \
  --arg slack "$SLACK_CHANNEL" --arg discord "$DISCORD_CHANNEL" \
  --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '{
    teamId: $team,
    title: ("Release " + $tag),
    referenceKey: ("release-" + $tag),
    postDate: $now,
    status: "SCHEDULED",
    socialAccountTypes: ["SLACK", "DISCORD", "LINKEDIN", "TWITTER"],
    data: {
      SLACK:    { channelId: $slack,   text: ($name + "\n" + $notes[0:39880] + "\n" + $url) },
      DISCORD:  { channelId: $discord, text: ($name + "\n" + $notes[0:1880] + "\n" + $url) },
      LINKEDIN: { text: ($name + " is out.\n\n" + $notes[0:2880] + "\n\n" + $url) },
      TWITTER:  { text: ($name + " is out: " + $url) }
    }
  }')

# A 4xx or 5xx prints Siar's message and fails the job with exit code 22.
if ! created=$(curl -sS --fail-with-body -X POST "$API/post/" \
  -H "x-api-key: $SIAR_API_KEY" \
  -H "content-type: application/json" \
  -d "$body"); then
  printf '%s\n' "$created"
  exit 22
fi
id=$(printf '%s' "$created" | jq -r .id)
echo "Created post $id"

# Wait for each network's result, for up to 5 minutes.
for i in $(seq 1 30); do
  sleep 10
  post=$(curl -sS --fail-with-body "$API/post/$id" -H "x-api-key: $SIAR_API_KEY")
  status=$(printf '%s' "$post" | jq -r .status)
  case "$status" in
    POSTED) echo "Posted to each network."; exit 0 ;;
    ERROR)  printf '%s' "$post" | jq '.errors'; exit 1 ;;
  esac
done
echo "Still $status after 5 minutes."
exit 1

The CI step

# Example: .github/workflows/announce-release.yml
name: Announce release
on:
  release:
    types: [published]

jobs:
  announce:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Post release notes through Siar
        env:
          SIAR_API_KEY: ${{ secrets.SIAR_API_KEY }}
          SIAR_TEAM_ID: ${{ vars.SIAR_TEAM_ID }}
          SLACK_CHANNEL: ${{ vars.SIAR_SLACK_CHANNEL }}
          DISCORD_CHANNEL: ${{ vars.SIAR_DISCORD_CHANNEL }}
          TAG: ${{ github.event.release.tag_name }}
          NAME: ${{ github.event.release.name }}
          URL: ${{ github.event.release.html_url }}
          NOTES: ${{ github.event.release.body }}
        run: sh scripts/announce-release.sh

Pass the release text through environment variables, never by pasting it into the command line. Release notes often hold quotes and backticks.

How the job fails

What happenedExit codeWhat you see
Each network posted0"Posted to each network."
Siar refused the request (a field over a limit, a network not connected, a used referenceKey)22Siar's JSON message, printed by curl. Nothing was posted.
One or more networks failed1Each failed network's message and fix. The others still posted.
Still sending after 5 minutes1The last status. The post carries on; check it in the dashboard.
Example: a run where LinkedIn needed reconnecting
Created post POST_ID
{
  "LINKEDIN": "Reconnect this account, then retry the post."
}
Error: Process completed with exit code 1.

To send the failed network again, call POST /api/v1/post/{id}/retry. It re-sends only the networks that failed.

Variations

  • Fewer networks. Remove a network from socialAccountTypes and from data. Both must match.
  • Open networks only. Mastodon and Bluesky work the same way; see posting to Bluesky, Mastodon and Threads.
  • A bot name per project. Discord and Slack entries take username and avatarUrl.
  • Schedule for later. Set postDate to a future time; the job then only checks that the request was accepted.

Frequently asked questions

Can I post release notes to LinkedIn company pages?

Not yet. LinkedIn: personal profiles today; company pages open after LinkedIn grants page access.

What if the CI job runs twice for the same release?

The script sets referenceKey to release-. A second run gets 409 Conflict from Siar, curl exits with an error, and nothing is posted twice.

Do I need an SDK?

No. The script uses curl and jq, which most CI images have or can add in one line.