~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat(release): prepend docs/release_notes/<version>.md to release body (#3768)
LearningCircuit0f0707abea2e
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 4a544e8044..2c15144d54 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -359,6 +359,14 @@ jobs:with:egress-policy: audit+ - name: Sparse checkout release notes+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ sparse-checkout: docs/release_notes+ sparse-checkout-cone-mode: false+ fetch-depth: 1+ persist-credentials: false+- name: Download build artifactsuses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1with:@@ -376,12 +384,138 @@ jobs:- name: Create GitHub Releaserun: |- # Create the release using GitHub CLI with auto-generated notes+ # Compose the release body before creation so the published body is+ # final on first publish (no edit-after window where downstream+ # workflows could see partial notes).+ #+ # Body layout (each section is omitted if its source is empty):+ # 1. AI-generated TL;DR (from OpenRouter, model = vars.AI_MODEL)+ # 2. Hand-written notes from docs/release_notes/<version>.md+ # 3. Horizontal rule+ # 4. Auto-generated, label-categorized PR list (already starts+ # with "## What's Changed", emitted by GitHub's generate-notes+ # API driven by .github/release.yml)+ #+ # The AI step is best-effort: if OPENROUTER_API_KEY is unset or the+ # call fails, we fall through silently with no AI section. Releases+ # must never fail because of an LLM hiccup.+ set -euo pipefail++ # Defense-in-depth: reject anything that could escape docs/release_notes/+ # via path traversal. RELEASE_VERSION is the bare semver (no `v`+ # prefix) — the build job's "Determine version" step strips+ # `refs/tags/v` for tag pushes and reads __version__.py (bare+ # "1.6.7") otherwise. A leading `v` here would mean an upstream+ # contract change and should fail loudly rather than silently miss+ # the notes file (`docs/release_notes/v1.7.0.md` does not exist).+ if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][a-zA-Z0-9.+_-]+)?$ ]]; then+ echo "ERROR: RELEASE_VERSION '$RELEASE_VERSION' is not a valid bare semver string" >&2+ exit 1+ fi++ RELEASE_NOTES_FILE="docs/release_notes/${RELEASE_VERSION}.md"+ NOTES_FILE="$(mktemp)"+ PROMPT_FILE="$(mktemp)"+ AI_RESPONSE_FILE="$(mktemp)"+ trap 'rm -f "$NOTES_FILE" "$PROMPT_FILE" "$AI_RESPONSE_FILE"' EXIT++ # `set -e` does NOT exit on a failing command substitution in an+ # assignment, so wrap with explicit failure handling.+ if ! AUTO_BODY=$(gh api -X POST \+ "/repos/${GITHUB_REPOSITORY}/releases/generate-notes" \+ -f tag_name="${RELEASE_TAG}" \+ -q .body); then+ echo "ERROR: gh api generate-notes failed for $RELEASE_TAG" >&2+ exit 1+ fi++ HAND_NOTES=""+ if [[ -f "$RELEASE_NOTES_FILE" ]]; then+ HAND_NOTES=$(cat "$RELEASE_NOTES_FILE")+ fi++ # ---- AI TL;DR (best-effort) -----------------------------------------+ AI_SUMMARY=""+ if [[ -z "${OPENROUTER_API_KEY:-}" ]]; then+ echo "OPENROUTER_API_KEY not set — skipping AI summary"+ else+ # Compose the prompt: instructions (from $SUMMARY_PROMPT env)+ # followed by the two inputs, separated by clearly-labelled+ # markers (avoiding `---` which is a Markdown HR and could+ # confuse the model).+ {+ printf '%s\n' "$SUMMARY_PROMPT"+ printf '\n----- HAND-WRITTEN NOTES -----\n'+ if [[ -n "$HAND_NOTES" ]]; then+ printf '%s\n' "$HAND_NOTES"+ else+ printf '(none)\n'+ fi+ printf '\n----- AUTO-GENERATED PR LIST -----\n%s\n' "$AUTO_BODY"+ } > "$PROMPT_FILE"++ JSON_PAYLOAD=$(jq -n \+ --arg model "$AI_MODEL" \+ --rawfile content "$PROMPT_FILE" \+ --argjson temperature "$AI_TEMPERATURE" \+ --argjson max_tokens "$AI_MAX_TOKENS" \+ '{model:$model, messages:[{role:"user", content:$content}], temperature:$temperature, max_tokens:$max_tokens}')++ # Up to 2 attempts (1 retry) with a short backoff. The model+ # endpoint can hiccup on cold starts or transient rate-limits;+ # one retry covers nearly all of those without delaying releases.+ HTTP_CODE="000"+ for attempt in 1 2; do+ HTTP_CODE=$(printf '%s' "$JSON_PAYLOAD" | curl -sS \+ -o "$AI_RESPONSE_FILE" \+ -w '%{http_code}' \+ --max-time 120 \+ -X POST "https://openrouter.ai/api/v1/chat/completions" \+ -H "Content-Type: application/json" \+ -H "Authorization: Bearer $OPENROUTER_API_KEY" \+ -H "HTTP-Referer: https://github.com/${GITHUB_REPOSITORY}" \+ --data-binary @- || echo "000")+ if [[ "$HTTP_CODE" =~ ^2 ]]; then+ break+ fi+ echo "WARNING: AI summary attempt $attempt failed (HTTP $HTTP_CODE)"+ if [[ "$attempt" -eq 1 ]]; then+ echo "Retrying in 5s..."+ sleep 5+ fi+ done++ if [[ "$HTTP_CODE" =~ ^2 ]]; then+ AI_SUMMARY=$(jq -r '.choices[0].message.content // empty' "$AI_RESPONSE_FILE" 2>/dev/null || true)+ if [[ -n "$AI_SUMMARY" ]]; then+ echo "AI summary generated (model=$AI_MODEL, ${#AI_SUMMARY} chars)"+ else+ echo "WARNING: AI response 2xx but no .choices[0].message.content — skipping summary"+ fi+ else+ echo "WARNING: AI summary call failed (HTTP $HTTP_CODE) — skipping summary"+ fi+ fi+ # ---- end AI TL;DR ----------------------------------------------------++ {+ if [[ -n "$AI_SUMMARY" ]]; then+ printf '%s\n\n' "$AI_SUMMARY"+ fi+ if [[ -n "$HAND_NOTES" ]]; then+ printf '%s\n\n' "$HAND_NOTES"+ fi+ if [[ -n "$AI_SUMMARY" || -n "$HAND_NOTES" ]]; then+ printf -- '---\n\n'+ fi+ printf '%s\n' "$AUTO_BODY"+ } > "$NOTES_FILE"+# Includes SBOM files, Sigstore signatures, and SLSA provenancegh release create "$RELEASE_TAG" \--repo "$GITHUB_REPOSITORY" \--title "Release $RELEASE_VERSION" \- --generate-notes \+ --notes-file "$NOTES_FILE" \sbom-spdx.json \sbom-spdx.json.bundle \sbom-cyclonedx.json \@@ -394,6 +528,39 @@ jobs:GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}RELEASE_TAG: ${{ needs.build.outputs.tag }}RELEASE_VERSION: ${{ needs.build.outputs.version }}+ # Optional AI summarization. If OPENROUTER_API_KEY is not configured+ # in the release environment, the step skips the AI section silently.+ OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}+ AI_MODEL: ${{ vars.AI_MODEL || 'moonshotai/kimi-k2-thinking' }}+ AI_TEMPERATURE: ${{ vars.AI_RELEASE_SUMMARY_TEMPERATURE || '0.3' }}+ AI_MAX_TOKENS: ${{ vars.AI_RELEASE_SUMMARY_MAX_TOKENS || '4000' }}+ SUMMARY_PROMPT: >+ You are summarizing a software release for the project's GitHub release page.+ Two inputs follow: the hand-written release notes from the repository (may be empty)+ and the auto-generated, label-categorized list of merged pull requests.+++ Write the section a user would skim first to decide whether this release matters to them.+ Lead with the most user-facing change. If there are breaking changes, surface them next+ with a one-line "what to do" for each. Then notable new features and meaningful fixes.+ Skip dependency bumps, internal CI, refactors, and docs unless they're load-bearing for users.+++ Output plain GitHub-flavored markdown — no preamble, no closing meta-commentary.+ Open with the literal heading `## TL;DR`. Use `###` for any subsections inside it.+ Do not emit `#` (the release title above the body provides the H1) or anything+ deeper than `###`. Reference PRs only when they exist in the inputs (`#1234`+ style); never invent numbers, features, or behavior. If the hand-written notes+ contradict the PR list, trust the hand-written notes — they are the authoritative+ human narrative.+++ If both inputs are sparse, keep the summary to one or two sentences acknowledging+ this is a small/maintenance release.+++ Keep it dense: a short opening paragraph plus bullets, or 2–3 short paragraphs —+ whichever fits the material better. Aim for something a user can read in 30 seconds.trigger-workflows:needs: [build, create-release]diff --git a/.pre-commit-hooks/recommend-release-notes.py b/.pre-commit-hooks/recommend-release-notes.pyindex 401a42ec40..de886c321a 100755--- a/.pre-commit-hooks/recommend-release-notes.py+++ b/.pre-commit-hooks/recommend-release-notes.py@@ -1,8 +1,11 @@#!/usr/bin/env python3-"""Remind contributors to update release notes for substantial changes.+"""Remind contributors about release notes.-Always exits 0 (non-blocking). Prints a suggestion when source changes-are substantial but no files under docs/release_notes/ are staged.+Always exits 0 (non-blocking). Two messages:+- When any file under docs/release_notes/ is staged: confirm that the+ file ends up in the GitHub release body and give brief format tips.+- When source changes are substantial but no release-notes file is+ staged: nudge the contributor to add one."""import subprocess@@ -13,36 +16,98 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))from _commit_analysis import analyze_commit-# Minimum added source lines before the reminder fires+# Minimum added source lines before the nudge firesMIN_SOURCE_ADDED = 20+# Phrases that mark a file as in-progress staging text rather than+# ready-to-publish release prose. These would otherwise publish verbatim+# into the GitHub release body — the workflow prepends the file as-is.+STAGING_MARKERS = (+ "(pending)",+ "Staging notes",+ "Fold into the next tagged version",+)+def _release_notes_staged():- """Return True if any file under docs/release_notes/ is staged."""+ """Return the list of staged files under docs/release_notes/."""result = subprocess.run(["git", "diff", "--cached", "--name-only", "--", "docs/release_notes/"],capture_output=True,text=True,)- return bool(result.stdout.strip())+ return [line for line in result.stdout.strip().splitlines() if line]-def main():- analysis = analyze_commit()-- # Silent exit: no source files staged- if not analysis.source_files:- return 0-- # Silent exit: trivial change (less than MIN_SOURCE_ADDED added lines)- if analysis.total_source_added < MIN_SOURCE_ADDED:- return 0+def _scan_staging_markers(path):+ """Return a list of (line_num, marker, snippet) for each staging marker+ found in the staged version of ``path``. Empty list if the file is+ being deleted or has no markers."""+ result = subprocess.run(+ ["git", "show", f":{path}"],+ capture_output=True,+ text=True,+ )+ if result.returncode != 0:+ return []+ hits = []+ for i, line in enumerate(result.stdout.splitlines(), start=1):+ lowered = line.lower()+ for marker in STAGING_MARKERS:+ if marker.lower() in lowered:+ snippet = line.strip()+ if len(snippet) > 80:+ snippet = snippet[:77] + "..."+ hits.append((i, marker, snippet))+ break+ return hits+++def _print_staged_notice(staged):+ """Inform the committer that a release-notes file was staged."""+ print()+ print(" \033[36mRelease Notes Staged\033[0m")+ print(" " + "-" * 40)+ for f in staged:+ print(f" - {f}")+ print()+ print(" Files matching docs/release_notes/<version>.md are prepended")+ print(" to the GitHub release body when that tag is cut")+ print(" (.github/workflows/release.yml).")++ # Warn (non-blocking) if any staged file still contains staging markers.+ # These would publish verbatim into the release body.+ findings = {f: _scan_staging_markers(f) for f in staged}+ findings = {f: hits for f, hits in findings.items() if hits}+ if findings:+ print()+ print(+ " \033[33m⚠ Staging markers detected — will publish verbatim:\033[0m"+ )+ for f, hits in findings.items():+ print(f" {f}")+ for line_num, marker, snippet in hits:+ print(f" L{line_num} [{marker}]: {snippet}")+ print()+ print(" Strip these before tagging the release.")+ print()+ print(" Format tips:")+ print(" - Start with a short summary paragraph. No top-level `#`")+ print(" heading — the release title is rendered separately, so")+ print(" a leading H1 looks oversized.")+ print(" - Use `##` sections: BREAKING, New Features, Bug Fixes,")+ print(" Settings, Operational notes — only the ones that apply.")+ print(" - Mark breaking changes as `## BREAKING — <summary>` with")+ print(" an `### Impact` subsection listing who is affected.")+ print(" - Link PRs as `[#1234](https://github.com/.../pull/1234)`.")+ print(" - Before tagging: strip staging markers like `(pending)`")+ print(" or `Fold into the next tagged version` — they publish")+ print(" verbatim into the release body.")+ print()- # Silent exit: release notes already updated- if _release_notes_staged():- return 0- # Print reminder+def _print_missing_notice(analysis):+ """Nudge the committer to add release notes for a substantial change."""print()print(" \033[36mRelease Notes Reminder\033[0m")print(" " + "-" * 40)@@ -57,9 +122,32 @@ def main():print(f" - {f.path} (+{f.added})")print()print(" Consider adding an entry to docs/release_notes/ if this")- print(" change is user-facing or otherwise notable.")+ print(" change is user-facing or otherwise notable. Files matching")+ print(" the released <version>.md are auto-prepended to the GitHub")+ print(" release body when the tag is cut.")print()++def main():+ staged = _release_notes_staged()++ # Always inform when release notes are staged — contributors should+ # know the file gets published, not just archived as docs.+ if staged:+ _print_staged_notice(staged)+ return 0++ analysis = analyze_commit()++ # Silent exit: no source files staged+ if not analysis.source_files:+ return 0++ # Silent exit: trivial change (less than MIN_SOURCE_ADDED added lines)+ if analysis.total_source_added < MIN_SOURCE_ADDED:+ return 0++ _print_missing_notice(analysis)return 0