11#! /bin/bash
22
3- set -e -xv
4-
53# Get the latest tag
64v=$( 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)
1210syftui_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
1922prompt_template=$( cat << EOM
2023You 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,
6467EOM
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
7487if [ -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
7790fi
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
93106echo " $response " | jq -r ' .choices[0].message.content'
0 commit comments