Skip to content

Commit b0d952d

Browse files
committed
fix: enhance release notes script to handle empty commit logs and improve output formatting
1 parent 74dcb00 commit b0d952d

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

.github/workflows/draft-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ jobs:
269269
chmod +x ./scripts/generate-release-notes.sh
270270
271271
# Generate release notes and save to a file
272-
./scripts/generate-release-notes.sh > release_notes.md
272+
./scripts/generate-release-notes.sh | tee release_notes.md
273273
274274
# Update the release with the generated notes
275275
gh release edit ${{ needs.bump-version.outputs.version }} --notes-file release_notes.md

scripts/generate-release-notes.sh

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
set -e -xv
4-
53
# Get the latest tag
64
v=$(git tag --list | sort -V | tail -n 1)
75

@@ -12,20 +10,25 @@ prev_v=$(git tag --list | sort -V | tail -n 2 | head -n 1)
1210
syftui_commits=$(git --no-pager log --pretty=format:'%s' "$prev_v".."$v")
1311

1412
# Collect Daemon commit hashes and logs
15-
read h1 h2 < <(git --no-pager diff "$prev_v".."$v" -- src-daemon | tail -n 2 | awk '{print $3}')
16-
daemon_commits=$(cd src-daemon && git --no-pager log --pretty=format:'%s' "$h1".."$h2")
13+
daemon_diff=$(git --no-pager diff "$prev_v".."$v" -- src-daemon)
14+
if [ -n "$daemon_diff" ]; then
15+
read h1 h2 < <(echo "$daemon_diff" | tail -n 2 | awk '{print $3}')
16+
daemon_commits=$(cd src-daemon && git --no-pager log --pretty=format:'%s' "$h1".."$h2")
17+
else
18+
daemon_commits=""
19+
fi
1720

1821
# Compose the full prompt
1922
prompt_template=$(cat << EOM
2023
You are a release note generator for a desktop application project called SyftBox.
2124
22-
Here are the commit messages since the last version ($v):
25+
Here are the commit messages since the last version ($prev_v):
2326
2427
$syftui_commits
2528
2629
$daemon_commits
2730
28-
Write a concise, user-friendly release note with:
31+
Write a concise, user-friendly release note for $v with:
2932
- A high-level overview of the release.
3033
- Grouped and bulleted highlights under clear sections.
3134
- Plain English; minimal jargon.
@@ -64,15 +67,25 @@ This update delivers a smoother, more polished experience with dynamic theming,
6467
EOM
6568
)
6669

67-
echo -e "\033[1;36mGenerating release notes for the below new commits since $v\033[0m"
68-
echo -e "\n\033[1;33m=== SyftUI commits ===\033[0m"
69-
echo "$syftui_commits"
70-
echo -e "\n\033[1;33m=== Daemon commits ===\033[0m"
71-
echo "$daemon_commits"
70+
echo -e "\033[1;36mGenerating release notes for the below new commits since $prev_v\033[0m" >&2
71+
72+
echo -e "\n\033[1;33m=== SyftUI commits ===\033[0m" >&2
73+
if [ -n "$syftui_commits" ]; then
74+
echo "$syftui_commits" >&2
75+
else
76+
echo "<No SyftUI commits>" >&2
77+
fi
78+
79+
echo -e "\n\033[1;33m=== Daemon commits ===\033[0m" >&2
80+
if [ -n "$daemon_commits" ]; then
81+
echo "$daemon_commits" >&2
82+
else
83+
echo "<No Daemon commits>" >&2
84+
fi
7285

7386
# Ensure OPENROUTER_API_KEY is set
7487
if [ -z "$OPENROUTER_API_KEY" ]; then
75-
echo "Error: Please set OPENROUTER_API_KEY environment variable."
88+
echo "Error: Please set OPENROUTER_API_KEY environment variable." >&2
7689
exit 1
7790
fi
7891

@@ -89,5 +102,5 @@ response=$(curl -s https://openrouter.ai/api/v1/chat/completions \
89102
}')
90103

91104
# Extract and print content
92-
echo -e "\n\033[1;36mGenerated release notes:\033[0m"
105+
echo -e "\n\033[1;36mGenerated release notes:\033[0m" >&2
93106
echo "$response" | jq -r '.choices[0].message.content'

0 commit comments

Comments
 (0)