release_actions.yml

 1on:
 2  release:
 3    types: [published]
 4
 5jobs:
 6  discord_release:
 7    runs-on: ubuntu-latest
 8    steps:
 9    - name: Get appropriate URL
10      id: get-appropriate-url
11      run: |
12        if [ "${{ github.event.release.prerelease }}" == "true" ]; then
13          url="https://zed.dev/releases/preview/latest"
14        else
15          url="https://zed.dev/releases/stable/latest"
16        fi
17        echo "::set-output name=url::$url"
18
19    - name: Prepare release content
20      id: prepare-content
21      run: |
22        set -eu
23
24        text="📣 Zed ${{ github.event.release.tag_name }} was just released!\n\nRestart your Zed or head to ${{ steps.get-appropriate-url.outputs.URL }} to grab it.\n\n${{ github.event.release.body }}"
25
26        maxTextLength=2000
27        truncationIndicator="..."
28
29        if (( ${#text} > maxTextLength )); then
30            text=${text:0:maxTextLength - ${#truncationIndicator}}$truncationIndicator
31        fi
32
33        echo "::set-output name=content::$text"
34
35    - name: Discord Webhook Action
36      uses: tsickert/discord-webhook@v5.3.0
37      with:
38        webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
39        content: ${{ steps.prepare-content.outputs.content }}