chore: add release note generator
This commit is contained in:
56
scripts/generate-release-note.sh
Executable file
56
scripts/generate-release-note.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
repo_root="$(cd -- "$script_dir/.." && pwd)"
|
||||
prompt_file="${RELEASE_PROMPT_FILE:-"$repo_root/scripts/release-prompt.txt"}"
|
||||
|
||||
if ! command -v codex >/dev/null 2>&1; then
|
||||
echo "generate-release-note.sh: codex CLI is required but was not found in PATH." >&2
|
||||
exit 127
|
||||
fi
|
||||
|
||||
if [[ ! -f "$prompt_file" ]]; then
|
||||
echo "generate-release-note.sh: prompt file not found: $prompt_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
commit_messages="$(cat)"
|
||||
|
||||
if [[ -z "${commit_messages//[[:space:]]/}" ]]; then
|
||||
echo "generate-release-note.sh: expected commit messages on stdin." >&2
|
||||
echo "Example: git log --oneline -n 20 | ./scripts/generate-release-note.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prompt_tmp="$(mktemp)"
|
||||
output_tmp="$(mktemp)"
|
||||
log_tmp="$(mktemp)"
|
||||
|
||||
cleanup() {
|
||||
rm -f "$prompt_tmp" "$output_tmp" "$log_tmp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
if [[ "$line" == *"<PASTE_COMMIT_MESSAGES_HERE>"* ]]; then
|
||||
printf '%s\n' "${line//<PASTE_COMMIT_MESSAGES_HERE>/$commit_messages}"
|
||||
else
|
||||
printf '%s\n' "$line"
|
||||
fi
|
||||
done < "$prompt_file" > "$prompt_tmp"
|
||||
|
||||
if ! codex \
|
||||
--ask-for-approval never \
|
||||
exec \
|
||||
--cd "$repo_root" \
|
||||
--ephemeral \
|
||||
--sandbox read-only \
|
||||
--color never \
|
||||
--output-last-message "$output_tmp" \
|
||||
- < "$prompt_tmp" > "$log_tmp" 2>&1; then
|
||||
cat "$log_tmp" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$output_tmp"
|
||||
Reference in New Issue
Block a user