community_release_actions.yml

 1name: Release Actions
 2
 3on:
 4  release:
 5    types: [published]
 6
 7jobs:
 8  discord_release:
 9    if: github.repository_owner == 'zed-industries'
10    runs-on: ubuntu-latest
11    steps:
12      - name: Get release URL
13        id: get-release-url
14        run: |
15          if [ "${{ github.event.release.prerelease }}" == "true" ]; then
16            URL="https://zed.dev/releases/preview/latest"
17          else
18            URL="https://zed.dev/releases/stable/latest"
19          fi
20          echo "URL=$URL" >> $GITHUB_OUTPUT
21      - name: Get content
22        uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1
23        id: get-content
24        with:
25          stringToTruncate: |
26            📣 Zed [${{ github.event.release.tag_name }}](<${{ steps.get-release-url.outputs.URL }}>) was just released!
27
28            ${{ github.event.release.body }}
29          maxLength: 2000
30          truncationSymbol: "..."
31      - name: Discord Webhook Action
32        uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0
33        with:
34          webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
35          content: ${{ steps.get-content.outputs.string }}
36
37  send_release_notes_email:
38    if: github.repository_owner == 'zed-industries' && !github.event.release.prerelease
39    runs-on: ubuntu-latest
40    steps:
41      - uses: actions/checkout@v4
42        with:
43          fetch-depth: 0
44      
45      - name: Check if release was promoted from preview
46        id: check-promotion-from-preview
47        run: |
48          VERSION="${{ github.event.release.tag_name }}"
49          PREVIEW_TAG="${VERSION}-pre"
50          if git rev-parse "$PREVIEW_TAG" >/dev/null 2>&1; then
51            echo "was_preview=true" >> $GITHUB_OUTPUT
52          else
53            echo "was_preview=false" >> $GITHUB_OUTPUT
54          fi
55
56      - name: Send release notes email
57        if: steps.check-promotion-from-preview.outputs.was_preview == 'true'
58        run: |
59          curl -X POST "https://zed.dev/api/send_release_notes_email" \
60            -H "Authorization: Bearer ${{ secrets.RELEASE_NOTES_API_TOKEN }}" \
61            -H "Content-Type: application/json" \
62            -d '{
63              "version": "${{ github.event.release.tag_name }}",
64              "markdown_body": ${{ toJSON(github.event.release.body) }}
65            }'