Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ The [release workflow (`.github/workflows/release.yml`)](https://github.com/lang

1. **Setup** - Resolves package name to working directory
2. **Build** - Creates distribution package
3. **Release Notes** + **Pre-release Checks** - Run in parallel; release notes extracts the changelog, appends a collapsible package-scoped Git log (newest commit first, up to 100 commits, truncated further if the log grows large), and collects contributor shoutouts; pre-release checks run tests against the built package
3. **Release Notes** + **Pre-release Checks** - Run in parallel; release notes extracts the changelog, appends a collapsible package-scoped Git log (newest commit first, up to 100 commits, truncated further if the log grows large), collects contributor shoutouts, and adds a **Special thanks** section crediting the users who filed the issues the release's PRs closed; pre-release checks run tests against the built package
4. **Test PyPI** - Publishes to test.pypi.org for validation (after pre-release checks pass)
5. **Publish** - Publishes to PyPI (requires Test PyPI to succeed)
6. **Mark Release** - Creates a published GitHub release with the built artifacts; updates PR labels. For the SDK (`libs/deepagents`), we set it as the repository's `latest` (unless it's a pre-release).
Expand Down
123 changes: 115 additions & 8 deletions .github/scripts/release/build_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,11 +928,22 @@ def _parse_socials(pr_body: str) -> Socials:
return Socials(twitter_match.group(1) if twitter_match else "", linkedin)


class IssueReporter(NamedTuple):
"""An issue author thanked in the Special thanks section.

`issues` holds closed-issue numbers, ascending and deduped.
"""

login: str
issues: list[int]


class Contributors(NamedTuple):
"""The community/internal split credited in the release notes."""

community: list[Contributor]
internal: list[str]
issue_reporters: list[IssueReporter]


def collect_contributors(
Expand All @@ -947,14 +958,15 @@ def collect_contributors(
) -> Contributors:
"""Collect community and internal contributors from merged PRs.

*internal* comes back sorted; *community* keeps commit order. The two are
disjoint: an org member is credited only as internal, regardless of what
labels their other PRs carry.
*internal* comes back sorted; *community* and *issue_reporters* keep commit
order. The two attribution sets are disjoint: an org member is credited only
as internal, regardless of what labels their other PRs carry, and is dropped
from the issue-reporter thanks as well.

Appends diagnostics to *warnings*.
"""
if offline:
return Contributors([], [])
return Contributors([], [], [])

range_spec = f"{prev_tag}..{release_commit}" if prev_tag else release_commit
commits_result = _git_run(repo, "rev-list", range_spec, "--", working_dir)
Expand All @@ -963,7 +975,7 @@ def collect_contributors(
f"contributor lookup: git rev-list failed for range '{range_spec}'"
f" ({commits_result.stderr.strip()}); no contributors will be credited"
)
return Contributors([], [])
return Contributors([], [], [])
all_shas = [
line.strip() for line in commits_result.stdout.splitlines() if line.strip()
]
Expand All @@ -979,6 +991,9 @@ def collect_contributors(

contributors: dict[str, Contributor] = {}
internal_users: set[str] = set()
# Insertion order mirrors the newest-first commit walk, so reporters render
# in the same order convention as community contributors.
reporters: dict[str, set[int]] = {}
seen_prs: set[str] = set()
failed_lookups = 0
consecutive_failures = 0
Expand Down Expand Up @@ -1013,14 +1028,18 @@ def collect_contributors(
continue
seen_prs.add(pr_num)

pr_data, view_error = _gh_pr_view(pr_num, repository, "author,body,labels")
pr_data, view_error = _gh_pr_view(
pr_num, repository, "author,body,labels,closingIssuesReferences"
)
if pr_data is None:
failed_lookups += 1
warnings.append(
f"contributor lookup: gh pr view #{pr_num} failed: {view_error}"
)
continue

_collect_issue_reporters(pr_num, pr_data, reporters, warnings)

author = pr_data.get("author")
if not isinstance(author, dict):
warnings.append(
Expand Down Expand Up @@ -1096,8 +1115,70 @@ def collect_contributors(
# other PRs carry, so they are credited only in the internal list.
for user in internal_users:
contributors.pop(user, None)
reporters.pop(user, None)

return Contributors(list(contributors.values()), sorted(internal_users))
issue_reporters = [
IssueReporter(login, sorted(issues)) for login, issues in reporters.items()
]
return Contributors(
list(contributors.values()), sorted(internal_users), issue_reporters
)


def _collect_issue_reporters(
pr_num: str,
pr_data: dict,
reporters: dict[str, set[int]],
warnings: list[str],
) -> None:
"""Fold a PR's closed-issue authors into *reporters*.

Runs before the author/labels gates in :func:`collect_contributors`, so a
bot-authored or `internal`-labeled PR still credits the human who filed the
issue it closed; the internal sweep afterwards drops reporters who are
themselves internal to this release.

`closingIssuesReferences` covers both the `Closes`/`Fixes`/`Resolves`
keywords and issues linked manually in the PR's Development section. Its
`author` payload has no `is_bot` field, so bots are caught by the login
suffix only. A missing or null field warns rather than being read as "no
closed issues": schema drift must not silently empty the section.
"""
if pr_data.get("closingIssuesReferences") is None:
warnings.append(
f"contributor lookup: PR #{pr_num} returned no"
" closingIssuesReferences field; the special-thanks section may be"
" incomplete"
)
issues = pr_data.get("closingIssuesReferences") or []
if not isinstance(issues, list):
warnings.append(
f"contributor lookup: PR #{pr_num} has an unexpected"
" closingIssuesReferences payload; its closed issues will not be"
" credited"
)
return
for issue in issues:
if not isinstance(issue, dict):
continue
author = issue.get("author")
login = author.get("login") if isinstance(author, dict) else None
if not login:
Comment thread
robin-agent[bot] marked this conversation as resolved.
Resolved
warnings.append(
f"contributor lookup: PR #{pr_num} closes an issue with no"
" author login; reporter will not appear in release notes"
)
continue
if login.endswith("[bot]"):
continue
number = issue.get("number")
if not isinstance(number, int):
warnings.append(
f"contributor lookup: PR #{pr_num} closes an issue with no"
" usable number; reporter will not appear in release notes"
)
continue
reporters.setdefault(login, set()).add(number)


def _merged_by(repository: str, pr_num: str, warnings: list[str]) -> str:
Expand Down Expand Up @@ -1211,6 +1292,7 @@ def build_base_body(
is_prerelease: bool,
community: list[Contributor],
internal: list[str],
issue_reporters: list[IssueReporter],
releaser: str,
base_branch: str,
default_branch: str,
Expand All @@ -1237,6 +1319,23 @@ def build_base_body(
body += f"\n\n---\n\nThanks to our community contributors: {entries}"
separator_added = True

if issue_reporters:
if not separator_added:
body += "\n\n---"
separator_added = True
lines = "\n".join(
f"- @{r.login} — "
+ ", ".join(
f"[#{n}](https://github.com/{repository}/issues/{n})"
for n in r.issues
)
for r in issue_reporters
)
body += (
"\n\n**Special thanks** to everyone who reported the issues addressed"
f" in this release:\n\n{lines}"
)

if internal:
if not separator_added:
body += "\n\n---"
Expand Down Expand Up @@ -1475,14 +1574,15 @@ def build_release_notes(
warnings.append("Offline mode: skipping contributor and releaser lookups.")
community: list[Contributor] = []
internal: list[str] = []
issue_reporters: list[IssueReporter] = []
releaser = ""
else:
# Deliberately bounded by release_commit, not release_sha: the git log
# above shows everything that shipped, while attribution stops at the
# release commit so commits merged after it are not credited here. For
# a stable release the two differ whenever anything landed between the
# changelog bump and the release SHA.
community, internal = collect_contributors(
community, internal, issue_reporters = collect_contributors(
repo_root,
working_dir,
release_commit,
Expand All @@ -1501,6 +1601,12 @@ def build_release_notes(
)
if internal:
print(f"Found internal maintainers: {', '.join(internal)}", file=sys.stderr)
if issue_reporters:
print(
"Found issue reporters: "
+ ", ".join(r.login for r in issue_reporters),
file=sys.stderr,
)
if releaser:
print(f"Found releaser: @{releaser}", file=sys.stderr)

Expand All @@ -1511,6 +1617,7 @@ def build_release_notes(
is_prerelease=is_pre,
community=community,
internal=internal,
issue_reporters=issue_reporters,
releaser=releaser,
base_branch=base_branch,
default_branch=default_branch,
Expand Down
Loading
Loading