Add deterministic release notes fallback
This commit is contained in:
parent
a6a8f0a8ef
commit
8330664ed2
1 changed files with 137 additions and 6 deletions
|
|
@ -224,6 +224,132 @@ JSON
|
||||||
printf '%s' "$content"
|
printf '%s' "$content"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Pretty-print a section of notes (expects array name)
|
||||||
|
print_section() {
|
||||||
|
local ref="$1"
|
||||||
|
declare -n arr_ref="$ref"
|
||||||
|
if [ ${#arr_ref[@]} -eq 0 ]; then
|
||||||
|
echo "None"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local item
|
||||||
|
for item in "${arr_ref[@]}"; do
|
||||||
|
echo "- ${item}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Deterministic fallback when no LLM providers are available
|
||||||
|
generate_fallback_release_notes() {
|
||||||
|
local subjects=()
|
||||||
|
mapfile -t subjects < <(echo "$COMMIT_LOG" | sed 's/^[0-9a-f]\+ //')
|
||||||
|
|
||||||
|
local features=()
|
||||||
|
local bugs=()
|
||||||
|
local improvements=()
|
||||||
|
local breakings=()
|
||||||
|
|
||||||
|
local subject lower
|
||||||
|
for subject in "${subjects[@]}"; do
|
||||||
|
[ -z "$subject" ] && continue
|
||||||
|
lower=$(echo "$subject" | tr '[:upper:]' '[:lower:]')
|
||||||
|
if [[ "$lower" =~ (feat|feature|add|introduc|support|new) ]]; then
|
||||||
|
features+=("$subject")
|
||||||
|
elif [[ "$lower" =~ (fix|bug|issue|patch|regress|correct) ]]; then
|
||||||
|
bugs+=("$subject")
|
||||||
|
elif [[ "$lower" =~ (breaking|deprecat|remove|drop|incompatib) ]]; then
|
||||||
|
breakings+=("$subject")
|
||||||
|
else
|
||||||
|
improvements+=("$subject")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#improvements[@]} -eq 0 ] && [ ${#features[@]} -eq 0 ] && [ ${#bugs[@]} -eq 0 ]; then
|
||||||
|
improvements=("${subjects[@]}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
local notes=()
|
||||||
|
for subject in "${subjects[@]}"; do
|
||||||
|
notes+=("$subject")
|
||||||
|
[ ${#notes[@]} -ge 3 ] && break
|
||||||
|
done
|
||||||
|
if [ ${#notes[@]} -eq 0 ]; then
|
||||||
|
notes+=("Routine maintenance and dependency updates.")
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "## What's Changed"
|
||||||
|
echo ""
|
||||||
|
echo "### New Features"
|
||||||
|
print_section features
|
||||||
|
echo ""
|
||||||
|
echo "### Bug Fixes"
|
||||||
|
print_section bugs
|
||||||
|
echo ""
|
||||||
|
echo "### Improvements"
|
||||||
|
print_section improvements
|
||||||
|
echo ""
|
||||||
|
echo "### Breaking Changes"
|
||||||
|
print_section breakings
|
||||||
|
echo ""
|
||||||
|
echo "## Installation"
|
||||||
|
echo ""
|
||||||
|
echo "**Quick Install (systemd / LXC / Proxmox VE):**"
|
||||||
|
cat <<'EOQI'
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/rcourtman/Pulse/main/install.sh | bash
|
||||||
|
```
|
||||||
|
EOQI
|
||||||
|
echo ""
|
||||||
|
echo "**Docker:**"
|
||||||
|
cat <<EOQDock
|
||||||
|
```bash
|
||||||
|
docker pull rcourtman/pulse:v${VERSION}
|
||||||
|
docker stop pulse && docker rm pulse
|
||||||
|
docker run -d --name pulse \\
|
||||||
|
--restart unless-stopped \\
|
||||||
|
-p 7655:7655 -p 7656:7656 \\
|
||||||
|
-v /opt/pulse/data:/data \\
|
||||||
|
rcourtman/pulse:v${VERSION}
|
||||||
|
```
|
||||||
|
EOQDock
|
||||||
|
echo ""
|
||||||
|
echo "**Manual Binary (amd64 example):**"
|
||||||
|
cat <<EOQMan
|
||||||
|
```bash
|
||||||
|
curl -LO https://github.com/rcourtman/Pulse/releases/download/v${VERSION}/pulse-v${VERSION}-linux-amd64.tar.gz
|
||||||
|
sudo systemctl stop pulse
|
||||||
|
sudo tar -xzf pulse-v${VERSION}-linux-amd64.tar.gz -C /usr/local/bin pulse
|
||||||
|
sudo systemctl start pulse
|
||||||
|
```
|
||||||
|
EOQMan
|
||||||
|
echo ""
|
||||||
|
echo "**Helm:**"
|
||||||
|
cat <<EOQHelm
|
||||||
|
```bash
|
||||||
|
helm upgrade --install pulse oci://ghcr.io/rcourtman/pulse-chart \\
|
||||||
|
--version ${VERSION} \\
|
||||||
|
--namespace pulse \\
|
||||||
|
--create-namespace
|
||||||
|
```
|
||||||
|
EOQHelm
|
||||||
|
echo ""
|
||||||
|
echo "## Downloads"
|
||||||
|
echo "- Universal tarball (auto-detects architecture): \`pulse-v${VERSION}.tar.gz\`"
|
||||||
|
echo "- Architecture-specific: \`amd64\`, \`arm64\`, \`armv7\`, \`armv6\`, \`386\`"
|
||||||
|
echo "- Host agent packages: macOS, Windows, Linux"
|
||||||
|
echo "- Sensor proxy binaries: Linux (amd64/arm64/armv7/armv6/386)"
|
||||||
|
echo "- Helm chart: \`pulse-${VERSION}.tgz\`"
|
||||||
|
echo "- SHA256 checksums: \`checksums.txt\`"
|
||||||
|
echo ""
|
||||||
|
echo "## Notes"
|
||||||
|
local item
|
||||||
|
for item in "${notes[@]}"; do
|
||||||
|
echo "- ${item}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Call LLM API based on provider with graceful fallback
|
# Call LLM API based on provider with graceful fallback
|
||||||
RELEASE_NOTES=""
|
RELEASE_NOTES=""
|
||||||
if [ "$LLM_PROVIDER" = "anthropic" ]; then
|
if [ "$LLM_PROVIDER" = "anthropic" ]; then
|
||||||
|
|
@ -231,22 +357,27 @@ if [ "$LLM_PROVIDER" = "anthropic" ]; then
|
||||||
if [ -n "${OPENAI_API_KEY:-}" ]; then
|
if [ -n "${OPENAI_API_KEY:-}" ]; then
|
||||||
echo "Anthropic generation failed, falling back to OpenAI..." >&2
|
echo "Anthropic generation failed, falling back to OpenAI..." >&2
|
||||||
if ! RELEASE_NOTES=$(generate_with_openai); then
|
if ! RELEASE_NOTES=$(generate_with_openai); then
|
||||||
echo "Error: OpenAI fallback failed as well" >&2
|
echo "OpenAI fallback failed; generating heuristic release notes." >&2
|
||||||
exit 1
|
RELEASE_NOTES=$(generate_fallback_release_notes)
|
||||||
fi
|
fi
|
||||||
LLM_PROVIDER="openai"
|
LLM_PROVIDER="openai"
|
||||||
else
|
else
|
||||||
echo "Error: Failed to generate release notes via Anthropic and no OpenAI fallback is available" >&2
|
echo "Anthropic generation failed and no OpenAI fallback is available; generating heuristic release notes." >&2
|
||||||
exit 1
|
RELEASE_NOTES=$(generate_fallback_release_notes)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if ! RELEASE_NOTES=$(generate_with_openai); then
|
if ! RELEASE_NOTES=$(generate_with_openai); then
|
||||||
echo "Error: Failed to generate release notes via OpenAI" >&2
|
echo "OpenAI generation failed; generating heuristic release notes." >&2
|
||||||
exit 1
|
RELEASE_NOTES=$(generate_fallback_release_notes)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_NOTES" ] || [ "$RELEASE_NOTES" = "null" ]; then
|
||||||
|
echo "Error: Release notes generation returned empty content" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Output release notes
|
# Output release notes
|
||||||
echo ""
|
echo ""
|
||||||
echo "Generated release notes:"
|
echo "Generated release notes:"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue