diff --git a/.github/release/publish-discord.sh b/.github/release/publish-discord.sh new file mode 100755 index 00000000000..b22e13c1ee7 --- /dev/null +++ b/.github/release/publish-discord.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# publish-discord.sh: announces the v release in Discord with OPENCODE_RELEASE_NOTES (DISCORD_WEBHOOK). +# Discord caps an embed description at 4096 characters, so longer notes are cut and link to the GitHub release. +. "$(dirname "$0")/lib.sh" + +tag="v$OPENCODE_VERSION" +payload=$(jq -n --arg tag "$tag" --arg notes "${OPENCODE_RELEASE_NOTES:-}" \ + --arg url "https://github.com/$GITHUB_REPOSITORY/releases/tag/$tag" ' + ($notes | if length > 4000 then .[:4000] + "\n\n[Full release notes](\($url))" else . end) as $description | + { + allowed_mentions: {parse: []}, + embeds: [{title: "OpenCode V2 \($tag)", url: $url, color: 2829099} + if $description == "" then {} else {description: $description} end] + }') +echo "$payload" | jq . +if dry_run; then exit 0; fi + +test -n "${DISCORD_WEBHOOK:-}" || die "DISCORD_WEBHOOK is not set" +curl -fsS --retry 3 -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd560df277a..fead99408e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -733,6 +733,22 @@ jobs: GH_REPO: ${{ github.repository }} OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }} + publish-discord: + needs: [plan, publish-github-release] + if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }} + runs-on: ubuntu-24.04 + environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }} + permissions: + contents: read + env: *env + steps: + - *checkout-release + - name: Publish + run: bash .github/release/publish-discord.sh + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }} + # Brings the release commit back to dev. Pushing to dev is blocked by rulesets, so it opens a PR. publish-version-pr: needs: [plan, tag, publish-npm, publish-cli, publish-desktop, publish-github-release]