From 5f7843f70fb8bde879f76547a73bd79a0bda32b6 Mon Sep 17 00:00:00 2001 From: Konstantin Sivakov Date: Mon, 16 Nov 2026 14:03:51 +0100 Subject: [PATCH 1/3] List only commits not yet released in the release PR Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-pr.yml | 36 +++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index eb4bd01..50fe0be 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -115,14 +115,38 @@ jobs: - name: Check for unreleased changes id: check env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + REPO: ${{ github.repository }} STAGING: ${{ inputs.staging-branch }} BASE: ${{ inputs.base-branch }} run: | set -euo pipefail + # Release PRs are squash merged, so the commits they shipped never become + # ancestors of BASE. The head of the last merged one marks what shipped. + SINCE="" + if LAST=$(gh pr list --repo "${REPO}" --base "${BASE}" --head "${STAGING}" \ + --state merged --limit 20 --json headRefOid,mergedAt \ + --jq 'sort_by(.mergedAt) | last | .headRefOid // empty'); then + if [ -z "$LAST" ]; then + echo "No merged release PR yet. Listing every commit not on ${BASE}." + elif git merge-base --is-ancestor "$LAST" "origin/${STAGING}"; then + SINCE="$LAST" + else + echo "::warning::Last release head ${LAST} is not on ${STAGING}. Listing every commit not on ${BASE}." + fi + else + echo "::warning::Could not look up the last merged release PR. Listing every commit not on ${BASE}." + fi + echo "since=${SINCE}" >> "$GITHUB_OUTPUT" + + RANGE=("origin/${STAGING}" "^origin/${BASE}") + if [ -n "$SINCE" ]; then + RANGE+=("^${SINCE}") + fi if git diff --quiet "origin/${BASE}" "origin/${STAGING}"; then AHEAD=0 else - AHEAD=$(git rev-list --count "origin/${BASE}..origin/${STAGING}") + AHEAD=$(git rev-list --count "${RANGE[@]}") fi echo "ahead=$AHEAD" >> "$GITHUB_OUTPUT" if [ "$AHEAD" -eq 0 ]; then @@ -140,11 +164,17 @@ jobs: STAGING: ${{ inputs.staging-branch }} BASE: ${{ inputs.base-branch }} FROZEN: ${{ steps.freeze.outputs.frozen }} + SINCE: ${{ steps.check.outputs.since }} run: | set -euo pipefail - COMMITS=$(git log --oneline --no-merges "origin/${BASE}..origin/${STAGING}") - CONTRIBUTORS=$(git log --format='%an' "origin/${BASE}..origin/${STAGING}" | sort -u | sed 's/^/- /') + RANGE=("origin/${STAGING}" "^origin/${BASE}") + if [ -n "$SINCE" ]; then + RANGE+=("^${SINCE}") + fi + + COMMITS=$(git log --oneline --no-merges "${RANGE[@]}") + CONTRIBUTORS=$(git log --format='%an' "${RANGE[@]}" | sort -u | sed 's/^/- /') # Find the PR before writing about it. The body describes whether this is # a draft, and only the PR itself knows that: an existing PR may already From 14969ac09acdcc182e939d20e99b1819ee293b67 Mon Sep 17 00:00:00 2001 From: Konstantin Sivakov Date: Mon, 16 Nov 2026 14:04:14 +0100 Subject: [PATCH 2/3] Cap the release PR commit list so the body stays under the GitHub limit Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-pr.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 50fe0be..fbaec30 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -173,7 +173,15 @@ jobs: RANGE+=("^${SINCE}") fi - COMMITS=$(git log --oneline --no-merges "${RANGE[@]}") + # GitHub rejects a PR body over 65536 characters, so a long queue lists + # only the newest commits and links the full comparison. + MAX_LISTED=250 + TOTAL=$(git rev-list --count --no-merges "${RANGE[@]}") + COMMITS=$(git log --oneline --no-merges --max-count="${MAX_LISTED}" "${RANGE[@]}") + OVERFLOW_LINE="" + if [ "$TOTAL" -gt "$MAX_LISTED" ]; then + OVERFLOW_LINE="Showing the newest ${MAX_LISTED} of ${TOTAL} commits. [Full list](https://github.com/${REPO}/compare/${SINCE:-$BASE}...${STAGING})" + fi CONTRIBUTORS=$(git log --format='%an' "${RANGE[@]}" | sort -u | sed 's/^/- /') # Find the PR before writing about it. The body describes whether this is @@ -215,6 +223,7 @@ jobs: \`\`\` ${COMMITS} \`\`\` + ${OVERFLOW_LINE} ### Contributors ${CONTRIBUTORS} From b062fa43e4f66e39917ab3222d887b74eb993355 Mon Sep 17 00:00:00 2001 From: Konstantin Sivakov Date: Mon, 16 Nov 2026 14:16:10 +0100 Subject: [PATCH 3/3] Bound the release PR body by characters and count only listed commits Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-pr.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index fbaec30..44e3d47 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -125,10 +125,12 @@ jobs: # ancestors of BASE. The head of the last merged one marks what shipped. SINCE="" if LAST=$(gh pr list --repo "${REPO}" --base "${BASE}" --head "${STAGING}" \ - --state merged --limit 20 --json headRefOid,mergedAt \ - --jq 'sort_by(.mergedAt) | last | .headRefOid // empty'); then + --state merged --limit 20 --json headRefOid,mergedAt,isCrossRepository \ + --jq 'map(select(.isCrossRepository | not)) | sort_by(.mergedAt) | last | .headRefOid // empty'); then if [ -z "$LAST" ]; then echo "No merged release PR yet. Listing every commit not on ${BASE}." + elif ! [[ "$LAST" =~ ^[0-9a-f]{40}$ ]]; then + echo "::warning::The last release PR head is not a commit SHA. Listing every commit not on ${BASE}." elif git merge-base --is-ancestor "$LAST" "origin/${STAGING}"; then SINCE="$LAST" else @@ -146,7 +148,7 @@ jobs: if git diff --quiet "origin/${BASE}" "origin/${STAGING}"; then AHEAD=0 else - AHEAD=$(git rev-list --count "${RANGE[@]}") + AHEAD=$(git rev-list --count --no-merges "${RANGE[@]}") fi echo "ahead=$AHEAD" >> "$GITHUB_OUTPUT" if [ "$AHEAD" -eq 0 ]; then @@ -173,14 +175,27 @@ jobs: RANGE+=("^${SINCE}") fi - # GitHub rejects a PR body over 65536 characters, so a long queue lists - # only the newest commits and links the full comparison. + # GitHub rejects a PR body over 65536 characters. Subjects have no length + # limit, so the list is capped by characters as well as by count. MAX_LISTED=250 + LIST_BUDGET=50000 TOTAL=$(git rev-list --count --no-merges "${RANGE[@]}") - COMMITS=$(git log --oneline --no-merges --max-count="${MAX_LISTED}" "${RANGE[@]}") + CANDIDATES=$(git log --oneline --no-merges --max-count="${MAX_LISTED}" "${RANGE[@]}") + COMMITS="" + LISTED=0 + if [ -n "$CANDIDATES" ]; then + while IFS= read -r LINE; do + if [ $(( ${#COMMITS} + ${#LINE} + 1 )) -gt "$LIST_BUDGET" ]; then + break + fi + COMMITS+="${LINE}"$'\n' + LISTED=$((LISTED + 1)) + done <<< "$CANDIDATES" + fi + COMMITS="${COMMITS%$'\n'}" OVERFLOW_LINE="" - if [ "$TOTAL" -gt "$MAX_LISTED" ]; then - OVERFLOW_LINE="Showing the newest ${MAX_LISTED} of ${TOTAL} commits. [Full list](https://github.com/${REPO}/compare/${SINCE:-$BASE}...${STAGING})" + if [ "$TOTAL" -gt "$LISTED" ]; then + OVERFLOW_LINE="Showing the newest ${LISTED} of ${TOTAL} commits. [Compare](https://github.com/${REPO}/compare/${SINCE:-$BASE}...${STAGING})" fi CONTRIBUTORS=$(git log --format='%an' "${RANGE[@]}" | sort -u | sed 's/^/- /')