11name : Deploy & Announce Release
22
33on :
4- # Runs on pushes to the `main` branch
54 push :
65 branches : [main]
76
8- # Allow manual triggering from the Actions tab
97 workflow_dispatch :
108
11- # Permissions needed for GitHub Pages deployment
129permissions :
1310 contents : read
1411 pages : write
1512 id-token : write
1613
17- # Prevent overlapping deploys
1814concurrency :
1915 group : pages
2016 cancel-in-progress : false
2622 - name : ☁️ Checkout repository
2723 uses : actions/checkout@v4
2824 with :
29- fetch-depth : 0 # Needed for full commit history (e.g. for changelogs)
25+ fetch-depth : 0
3026
3127 - name : 🔧 Setup pnpm
3228 uses : pnpm/action-setup@v3
@@ -79,18 +75,17 @@ jobs:
7975 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8076 REPO : ${{ github.repository }}
8177 run : |
82- # Fetch latest merged PR to main
8378 curl -s -H "Authorization: token $GH_TOKEN" \
8479 "https://api.github.com/repos/$REPO/pulls?state=closed&base=main&sort=updated&direction=desc&per_page=1" \
8580 -o pr.json
8681
87- # Extract relevant fields
8882 PR_NUMBER=$(grep '"number":' pr.json | head -n 1 | awk '{print $2}' | tr -d ',')
8983 PR_TITLE=$(grep '"title":' pr.json | head -n 1 | cut -d ':' -f2- | sed 's/^ "//;s/",$//')
9084 PR_URL=$(grep '"html_url":' pr.json | head -n 1 | cut -d '"' -f4)
91- sed -n '/"body":/,$p' pr.json | sed '1s/.*"body": "//; s/",$//' > pr_body.md
85+ PR_BODY=$(awk -F'"body": "' '{print $2}' pr.json | sed 's/",$//')
86+
87+ echo "$PR_BODY" > pr_body.md
9288
93- # Export to env
9489 echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
9590 echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
9691 echo "PR_URL=$PR_URL" >> $GITHUB_ENV
@@ -99,17 +94,17 @@ jobs:
9994 id : extract
10095 run : |
10196 REPO="https://github.com/${{ github.repository }}"
102-
103- # Extract lines starting with '## ' from PR body (i.e., package names)
10497 grep '^## ' pr_body.md | sed 's/^## //' > packages.txt
10598
106- # Generate Telegram HTML links to each released package
107- while read -r line; do
108- ENCODED_TAG=$(printf "%s" "$line" | jq -sRr @uri)
109- echo " • <a href=\"$REPO/releases/tag/$ENCODED_TAG\">$line</a>"
110- done < packages.txt > release_links.html
99+ if [ -s packages.txt ]; then
100+ while read -r line; do
101+ ENCODED_TAG=$(printf "%s" "$line" | jq -sRr @uri)
102+ echo " • <a href=\"$REPO/releases/tag/$ENCODED_TAG\">$line</a>"
103+ done < packages.txt > release_links.html
104+ else
105+ echo " • No packages found." > release_links.html
106+ fi
111107
112- # Export formatted list to env
113108 {
114109 echo "RELEASE_LINKS<<EOF"
115110 cat release_links.html
@@ -123,7 +118,7 @@ jobs:
123118 token : ${{ secrets.TELEGRAM_TOKEN }}
124119 format : html
125120 message : |
126- 🚀 <b><a href="https://github.com/${{ github.repository }}">${{ github.repository }}</a></b> was just released!\n
127- 📦 <b>Released Packages:</b>\n
128- ${{ env.RELEASE_LINKS }}\n
129- 🔗 PR: <a href="${{ env.PR_URL }}"><b>${{ env.PR_TITLE }}</b> #${{ env.PR_NUMBER }}</a>
121+ 🚀 <b><a href="https://github.com/${{ github.repository }}">${{ github.repository }}</a></b> was just released!
122+ <b>Released Packages:</b>
123+ ${{ env.RELEASE_LINKS }}
124+ 🔗 <a href="${{ env.PR_URL }}"><b>${{ env.PR_TITLE }}</b> #${{ env.PR_NUMBER }}</a>
0 commit comments