Skip to content

Commit 17f4634

Browse files
authored
chore(release): announce releases in Discord again (#60371)
1 parent 7ed1f96 commit 17f4634

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎.github/release/publish-discord.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# publish-discord.sh: announces the v<version> release in Discord with OPENCODE_RELEASE_NOTES (DISCORD_WEBHOOK).
3+
# Discord caps an embed description at 4096 characters, so longer notes are cut and link to the GitHub release.
4+
. "$(dirname "$0")/lib.sh"
5+
6+
tag="v$OPENCODE_VERSION"
7+
payload=$(jq -n --arg tag "$tag" --arg notes "${OPENCODE_RELEASE_NOTES:-}" \
8+
--arg url "https://github.com/$GITHUB_REPOSITORY/releases/tag/$tag" '
9+
($notes | if length > 4000 then .[:4000] + "\n\n[Full release notes](\($url))" else . end) as $description |
10+
{
11+
allowed_mentions: {parse: []},
12+
embeds: [{title: "OpenCode V2 \($tag)", url: $url, color: 2829099} + if $description == "" then {} else {description: $description} end]
13+
}')
14+
echo "$payload" | jq .
15+
if dry_run; then exit 0; fi
16+
17+
test -n "${DISCORD_WEBHOOK:-}" || die "DISCORD_WEBHOOK is not set"
18+
curl -fsS --retry 3 -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK"

‎.github/workflows/release.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,22 @@ jobs:
733733
GH_REPO: ${{ github.repository }}
734734
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
735735

736+
publish-discord:
737+
needs: [plan, publish-github-release]
738+
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
739+
runs-on: ubuntu-24.04
740+
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
741+
permissions:
742+
contents: read
743+
env: *env
744+
steps:
745+
- *checkout-release
746+
- name: Publish
747+
run: bash .github/release/publish-discord.sh
748+
env:
749+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
750+
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
751+
736752
# Brings the release commit back to dev. Pushing to dev is blocked by rulesets, so it opens a PR.
737753
publish-version-pr:
738754
needs: [plan, tag, publish-npm, publish-cli, publish-desktop, publish-github-release]

0 commit comments

Comments
 (0)