GeezerVison is showing github.com — chore(release): announce releases in Discord again (#60371) · ogrman/opencode@17f4634
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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" |
Collapse file
Copy file name to clipboardExpand all lines: .github/workflows/release.yml +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -733,6 +733,22 @@ jobs: |
733 | 733 | GH_REPO: ${{ github.repository }} |
734 | 734 | OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }} |
735 | 735 |
|
| 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 | + |
736 | 752 | # Brings the release commit back to dev. Pushing to dev is blocked by rulesets, so it opens a PR. |
737 | 753 | publish-version-pr: |
738 | 754 | needs: [plan, tag, publish-npm, publish-cli, publish-desktop, publish-github-release] |
|