From d1e80d2b1151fed50e481a0e7b21e69662472204 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Fri, 5 Dec 2025 22:39:51 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A4=96=20feat:=20add=20Discord=20rele?= =?UTF-8?q?ase=20notification=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/discord-release-notify.yml | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/discord-release-notify.yml diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml new file mode 100644 index 0000000000..8177670136 --- /dev/null +++ b/.github/workflows/discord-release-notify.yml @@ -0,0 +1,48 @@ +name: Notify Discord on Release + +on: + release: + types: [published] # triggers when a release is published + +jobs: + notify-discord: + runs-on: ubuntu-latest + + steps: + - name: Send release notification to Discord + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_NAME: ${{ github.event.release.name }} + RELEASE_URL: ${{ github.event.release.html_url }} + RELEASE_BODY: ${{ github.event.release.body }} + REPO_NAME: ${{ github.repository }} + run: | + # Truncate body so we don't blow up Discord + BODY="${RELEASE_BODY}" + if [ ${#BODY} -gt 1500 ]; then + BODY="${BODY:0:1500}..." + fi + + # Build JSON payload (simple embed) + cat < payload.json + { + "username": "GitHub Releases", + "embeds": [ + { + "title": "New release: ${RELEASE_NAME:-$RELEASE_TAG}", + "url": "${RELEASE_URL}", + "description": "${BODY}", + "footer": { + "text": "${REPO_NAME}" + } + } + ] + } + EOF + + # Send to Discord + curl -X POST \ + -H "Content-Type: application/json" \ + -d @payload.json \ + "$DISCORD_WEBHOOK_URL" From 4f126f3aaf1441c4fca344448fc49ff9f7901ac9 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Fri, 5 Dec 2025 22:42:13 +0000 Subject: [PATCH 2/3] fix: use jq for JSON-safe payload construction --- .github/workflows/discord-release-notify.yml | 31 ++++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml index 8177670136..5a24102a1d 100644 --- a/.github/workflows/discord-release-notify.yml +++ b/.github/workflows/discord-release-notify.yml @@ -24,22 +24,21 @@ jobs: BODY="${BODY:0:1500}..." fi - # Build JSON payload (simple embed) - cat < payload.json - { - "username": "GitHub Releases", - "embeds": [ - { - "title": "New release: ${RELEASE_NAME:-$RELEASE_TAG}", - "url": "${RELEASE_URL}", - "description": "${BODY}", - "footer": { - "text": "${REPO_NAME}" - } - } - ] - } - EOF + # Build JSON payload with proper escaping via jq + jq -n \ + --arg title "New release: ${RELEASE_NAME:-$RELEASE_TAG}" \ + --arg url "$RELEASE_URL" \ + --arg body "$BODY" \ + --arg repo "$REPO_NAME" \ + '{ + username: "GitHub Releases", + embeds: [{ + title: $title, + url: $url, + description: $body, + footer: { text: $repo } + }] + }' > payload.json # Send to Discord curl -X POST \ From dac1d4db3d7e2488e0c5dc66a220bc1d33bcdd5e Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Fri, 12 Dec 2025 01:01:37 +0000 Subject: [PATCH 3/3] refactor: move Discord notification to release workflow job --- .github/workflows/discord-release-notify.yml | 47 ------------------- .github/workflows/release.yml | 48 ++++++++++++++++++++ 2 files changed, 48 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/discord-release-notify.yml diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml deleted file mode 100644 index 5a24102a1d..0000000000 --- a/.github/workflows/discord-release-notify.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Notify Discord on Release - -on: - release: - types: [published] # triggers when a release is published - -jobs: - notify-discord: - runs-on: ubuntu-latest - - steps: - - name: Send release notification to Discord - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - RELEASE_TAG: ${{ github.event.release.tag_name }} - RELEASE_NAME: ${{ github.event.release.name }} - RELEASE_URL: ${{ github.event.release.html_url }} - RELEASE_BODY: ${{ github.event.release.body }} - REPO_NAME: ${{ github.repository }} - run: | - # Truncate body so we don't blow up Discord - BODY="${RELEASE_BODY}" - if [ ${#BODY} -gt 1500 ]; then - BODY="${BODY:0:1500}..." - fi - - # Build JSON payload with proper escaping via jq - jq -n \ - --arg title "New release: ${RELEASE_NAME:-$RELEASE_TAG}" \ - --arg url "$RELEASE_URL" \ - --arg body "$BODY" \ - --arg repo "$REPO_NAME" \ - '{ - username: "GitHub Releases", - embeds: [{ - title: $title, - url: $url, - description: $body, - footer: { text: $repo } - }] - }' > payload.json - - # Send to Discord - curl -X POST \ - -H "Content-Type: application/json" \ - -d @payload.json \ - "$DISCORD_WEBHOOK_URL" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c05401b040..82bcb85e88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -172,3 +172,51 @@ jobs: run: bun x electron-builder --win --publish always env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + notify-discord: + name: Notify Discord + runs-on: ubuntu-latest + needs: [build-macos, build-linux, build-windows, build-vscode-extension] + if: github.event_name == 'release' + steps: + - name: Send release notification to Discord + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_NAME: ${{ github.event.release.name }} + RELEASE_URL: ${{ github.event.release.html_url }} + RELEASE_BODY: ${{ github.event.release.body }} + REPO_NAME: ${{ github.repository }} + run: | + if [ -z "$DISCORD_WEBHOOK_URL" ]; then + echo "DISCORD_WEBHOOK_URL not set; skipping Discord notification." + exit 0 + fi + + # Truncate body so we don't blow up Discord + BODY="${RELEASE_BODY}" + if [ ${#BODY} -gt 1500 ]; then + BODY="${BODY:0:1500}..." + fi + + # Build JSON payload with proper escaping via jq + jq -n \ + --arg title "New release: ${RELEASE_NAME:-$RELEASE_TAG}" \ + --arg url "$RELEASE_URL" \ + --arg body "$BODY" \ + --arg repo "$REPO_NAME" \ + '{ + username: "GitHub Releases", + embeds: [{ + title: $title, + url: $url, + description: $body, + footer: { text: $repo } + }] + }' > payload.json + + # Send to Discord + curl -X POST \ + -H "Content-Type: application/json" \ + -d @payload.json \ + "$DISCORD_WEBHOOK_URL"