diff --git a/.github/workflows/release-CI.yml b/.github/workflows/release-CI.yml index a2612d037..66d5d5185 100644 --- a/.github/workflows/release-CI.yml +++ b/.github/workflows/release-CI.yml @@ -202,3 +202,48 @@ jobs: run: | uv pip install --upgrade twine twine upload --skip-existing *.whl + + discord-notify: + name: Discord Release Notification + runs-on: ubuntu-latest + needs: [release] + if: always() && needs.release.result == 'success' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Build and send Discord notification + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + run: | + if [[ "$GITHUB_REF" != refs/tags/v* ]]; then + echo "::warning::GITHUB_REF ($GITHUB_REF) is not a tag push — skipping Discord notification" + exit 0 + fi + + VERSION="${GITHUB_REF#refs/tags/v}" + PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]' | sed -n '2p') + + if [ -z "$PREV_TAG" ]; then + CHANGELOG=$(git log --pretty=format:"- %s" --no-merges -20 | grep -v "^- Release " || true) + else + CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | grep -v "^- Release " || true) + fi + + read -r -d '' MESSAGE << EOM || true + Hey @everyone 👋 + + **Release Robyn v${VERSION}** + + ${CHANGELOG} + + Upgrade: \`pip install --upgrade robyn\` + + https://github.com/sparckles/Robyn/releases/tag/v${VERSION} + EOM + + PAYLOAD=$(jq -n --arg msg "$MESSAGE" '{content: $msg}') + + curl -f -H "Content-Type: application/json" \ + -d "$PAYLOAD" \ + "$DISCORD_WEBHOOK_URL"