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
21          echo "URL=$URL" >> "$GITHUB_OUTPUT"
22      - name: Get content
23        uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1
24        id: get-content
25        with:
26          stringToTruncate: |
27            📣 Zed [${{ github.event.release.tag_name }}](<${{ steps.get-release-url.outputs.URL }}>) was just released!
28
29            ${{ github.event.release.body }}
30          maxLength: 2000
31          truncationSymbol: "..."
32      - name: Discord Webhook Action
33        uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0
34        with:
35          webhook-url: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}
36          content: ${{ steps.get-content.outputs.string }}
37
38  send_release_notes_email:
39    if: github.repository_owner == 'zed-industries' && !github.event.release.prerelease
40    runs-on: ubuntu-latest
41    steps:
42      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
43        with:
44          fetch-depth: 0
45
46      - name: Check if release was promoted from preview
47        id: check-promotion-from-preview
48        run: |
49          VERSION="${{ github.event.release.tag_name }}"
50          PREVIEW_TAG="${VERSION}-pre"
51
52          if git rev-parse "$PREVIEW_TAG" > /dev/null 2>&1; then
53              echo "was_promoted_from_preview=true" >> "$GITHUB_OUTPUT"
54          else
55              echo "was_promoted_from_preview=false" >> "$GITHUB_OUTPUT"
56          fi
57
58      - name: Send release notes email
59        if: steps.check-promotion-from-preview.outputs.was_promoted_from_preview == 'true'
60        run: |
61          TAG="${{ github.event.release.tag_name }}"
62          cat << 'EOF' > release_body.txt
63          ${{ github.event.release.body }}
64          EOF
65          jq -n --arg tag "$TAG" --rawfile body release_body.txt '{version: $tag, markdown_body: $body}' \
66            > release_data.json
67          curl -X POST "https://zed.dev/api/send_release_notes_email" \
68            -H "Authorization: Bearer ${{ secrets.RELEASE_NOTES_API_TOKEN }}" \
69            -H "Content-Type: application/json" \
70            -d @release_data.json