From 3a4d517ac1015063a1d6453a275056de440a6cfa Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Thu, 16 Oct 2025 12:33:06 -0400 Subject: [PATCH 1/9] add comment-resolved-issues action --- .../comment-resolved-issues/action.yml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/actions/comment-resolved-issues/action.yml diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml new file mode 100644 index 00000000..59613bc0 --- /dev/null +++ b/.github/actions/comment-resolved-issues/action.yml @@ -0,0 +1,40 @@ +name: 'Comment on Resolved Issues' +description: 'Comments on issues referenced in PRs merged since last release' + +inputs: + token: + description: > + Personal access token (PAT) used to fetch the repository. The PAT is configured + with the local git config, which enables your scripts to run authenticated git + commands. The post-job step removes the PAT. + default: ${{ github.token }} + required: false + +runs: + using: composite + steps: + - name: Comment on issues + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + run: | + # Get the previous tag + PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') + + # Convert tag date to GitHub search format + TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/') + echo "Using tag date: $TAG_DATE" + + # Find issue numbers from PRs created from the last release tag date + ISSUE_NUMBERS=$(gh pr list \ + --json number,body,createdAt \ + --jq '.[] | select(.createdAt > "'$TAG_DATE'") | .body' | \ + grep -o 'issues/[0-9]*' | \ + sed 's/issues\///' + ) + + # Comment on each issue found + for issue_number in $ISSUE_NUMBERS; do + echo "Commenting on issue #$issue_number" + gh issue comment "$issue_number" --body "This issue was resolved and included in the latest release." || echo "Failed to comment on #$issue_number" + done From e733d1f081a7f4d5f5c0e0c47eb56c7fed226451 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 12:11:34 -0400 Subject: [PATCH 2/9] feedback --- .github/actions/comment-resolved-issues/action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index 59613bc0..875c0ac2 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -20,7 +20,8 @@ runs: run: | # Get the previous tag PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') - + CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p') + # Convert tag date to GitHub search format TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/') echo "Using tag date: $TAG_DATE" @@ -36,5 +37,5 @@ runs: # Comment on each issue found for issue_number in $ISSUE_NUMBERS; do echo "Commenting on issue #$issue_number" - gh issue comment "$issue_number" --body "This issue was resolved and included in the latest release." || echo "Failed to comment on #$issue_number" + gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG" || echo "Failed to comment on #$issue_number" done From 403c445be3cac38f837e2066e405c1b51d5241bd Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 13:50:00 -0400 Subject: [PATCH 3/9] feedback --- .../comment-resolved-issues/action.yml | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index 875c0ac2..d6537b1e 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -26,16 +26,38 @@ runs: TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/') echo "Using tag date: $TAG_DATE" - # Find issue numbers from PRs created from the last release tag date - ISSUE_NUMBERS=$(gh pr list \ - --json number,body,createdAt \ - --jq '.[] | select(.createdAt > "'$TAG_DATE'") | .body' | \ - grep -o 'issues/[0-9]*' | \ - sed 's/issues\///' + # Find all PRs merged from the last release tag date + ALL_PRS=$(gh pr list \ + --state merged \ + --json number,body,mergedAt \ + --jq '[.[] | select(.mergedAt > "$TAG_DATE") | .number]' ) - # Comment on each issue found - for issue_number in $ISSUE_NUMBERS; do - echo "Commenting on issue #$issue_number" - gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG" || echo "Failed to comment on #$issue_number" + # Find all issue number from PRs merged from the last release tag date + ISSUE_NUMBERS="" + for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do + + # Get the merge commit SHA for this PR + MERGE_COMMIT=$(gh pr view "$pr_number" --json mergeCommit --jq '.mergeCommit.oid') + + # Check if this commit exists in the release branch + if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then + echo "PR $pr_number is in release branch" + + # Get issue numbers from this PR + PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \ + grep -o 'issues/[0-9]*' | \ + sed 's/issues\///') + echo " Found issues: $PR_ISSUES" + + ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES" + fi done + + # Comment on each issue found + echo "$ISSUE_NUMBERS" | tr ' ' '\n' | while read -r issue_number; do + if [ -n "$issue_number" ]; then + echo "Commenting on issue #$issue_number" + gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG" || echo "::error Failed to comment on #$issue_number" + fi + done \ No newline at end of file From ded483f3065920b528b4e1f91868b3340236409b Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 13:50:51 -0400 Subject: [PATCH 4/9] comment --- .github/actions/comment-resolved-issues/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index d6537b1e..df7b613b 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -33,7 +33,7 @@ runs: --jq '[.[] | select(.mergedAt > "$TAG_DATE") | .number]' ) - # Find all issue number from PRs merged from the last release tag date + # Find all issue number from PRs merged into release branch ISSUE_NUMBERS="" for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do From f608014db2aa26537640771a4a835ecfadd1064d Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 14:18:14 -0400 Subject: [PATCH 5/9] fix --- .github/actions/comment-resolved-issues/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index df7b613b..91ae4029 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -30,7 +30,7 @@ runs: ALL_PRS=$(gh pr list \ --state merged \ --json number,body,mergedAt \ - --jq '[.[] | select(.mergedAt > "$TAG_DATE") | .number]' + --jq '[.[] | select(.mergedAt > "'$TAG_DATE'") | .number]' ) # Find all issue number from PRs merged into release branch From 1e85352ba5b14a63b7ff003e53f66d5d23051e85 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 14:42:20 -0400 Subject: [PATCH 6/9] feedback --- .github/actions/comment-resolved-issues/action.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index 91ae4029..cb540d52 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -18,6 +18,8 @@ runs: env: GH_TOKEN: ${{ inputs.token }} run: | + set -e + # Get the previous tag PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p') @@ -58,6 +60,9 @@ runs: echo "$ISSUE_NUMBERS" | tr ' ' '\n' | while read -r issue_number; do if [ -n "$issue_number" ]; then echo "Commenting on issue #$issue_number" - gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG" || echo "::error Failed to comment on #$issue_number" + if ! gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG"; then + echo "::error::Failed to comment on issue #$issue_number" + exit 1 + fi fi done \ No newline at end of file From 9bc808b439095f98806380c7b947de4749513ec5 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 14:45:55 -0400 Subject: [PATCH 7/9] cleanup --- .github/actions/comment-resolved-issues/action.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index cb540d52..dc989f7a 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -17,9 +17,7 @@ runs: shell: bash env: GH_TOKEN: ${{ inputs.token }} - run: | - set -e - + run: | # Get the previous tag PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p') From a60f832f037c2599bb827da15450f75df9d665c0 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 17 Oct 2025 17:14:27 -0400 Subject: [PATCH 8/9] feedback --- .../comment-resolved-issues/action.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index dc989f7a..2e71a5de 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -17,7 +17,7 @@ runs: shell: bash env: GH_TOKEN: ${{ inputs.token }} - run: | + run: | # Get the previous tag PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p') @@ -46,7 +46,7 @@ runs: # Get issue numbers from this PR PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \ - grep -o 'issues/[0-9]*' | \ + grep -o 'issues/[0-9]+' | \ sed 's/issues\///') echo " Found issues: $PR_ISSUES" @@ -55,12 +55,19 @@ runs: done # Comment on each issue found - echo "$ISSUE_NUMBERS" | tr ' ' '\n' | while read -r issue_number; do + FAILURES="" + + while read -r issue_number; do if [ -n "$issue_number" ]; then echo "Commenting on issue #$issue_number" - if ! gh issue comment "$issue_number" --body "A change related to this issue was included in release: $CURRENT_TAG"; then + if ! gh issue comment "$issue_number" --body "A change related to this issue was included in [release **$CURRENT_TAG**](https://github.com/${{ github.repository }}/releases/tag/$CURRENT_TAG)."; then echo "::error::Failed to comment on issue #$issue_number" - exit 1 + FAILURES="$FAILURES #$issue_number" fi fi - done \ No newline at end of file + done < <(echo "$ISSUE_NUMBERS" | tr ' ' '\n') + + if [ -n "$FAILURES" ]; then + echo "::error::Failed to update the following issue(s):$FAILURES" + exit 1 + fi \ No newline at end of file From 1e5c2b72e5fda145dc7fab4ecbd717d50e1e1128 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Mon, 20 Oct 2025 16:58:34 -0400 Subject: [PATCH 9/9] found issue in changelog, add pr link --- .../comment-resolved-issues/action.yml | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/actions/comment-resolved-issues/action.yml b/.github/actions/comment-resolved-issues/action.yml index 2e71a5de..f865982c 100644 --- a/.github/actions/comment-resolved-issues/action.yml +++ b/.github/actions/comment-resolved-issues/action.yml @@ -32,9 +32,11 @@ runs: --json number,body,mergedAt \ --jq '[.[] | select(.mergedAt > "'$TAG_DATE'") | .number]' ) - + # Find all issue number from PRs merged into release branch ISSUE_NUMBERS="" + FAILURES="" + for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do # Get the merge commit SHA for this PR @@ -44,29 +46,27 @@ runs: if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then echo "PR $pr_number is in release branch" - # Get issue numbers from this PR - PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \ - grep -o 'issues/[0-9]+' | \ - sed 's/issues\///') + # Get issue numbers from changelog entries in this PR + PR_ISSUES=$(gh pr view "$pr_number" --json files --jq '.files[].path' | \ + grep '\.changes/.*\.json$' | \ + xargs -I {} cat {} 2>/dev/null | \ + jq -r '.issues[]?' 2>/dev/null | \ + sed 's/.*#//') echo " Found issues: $PR_ISSUES" - ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES" + # Comment on each issue + for issue in $PR_ISSUES; do + if [ -n "$issue" ]; then + echo "Commenting on issue #$issue" + if ! gh issue comment "$issue" --body "A [change](https://github.com/${{ github.repository }}/pull/$pr_number) related to this issue was included in [**$CURRENT_TAG**](https://github.com/${{ github.repository }}/releases/tag/$CURRENT_TAG)."; then + echo "::error::Failed to comment on issue #$issue" + FAILURES="$FAILURES #$issue" + fi + fi + done fi done - # Comment on each issue found - FAILURES="" - - while read -r issue_number; do - if [ -n "$issue_number" ]; then - echo "Commenting on issue #$issue_number" - if ! gh issue comment "$issue_number" --body "A change related to this issue was included in [release **$CURRENT_TAG**](https://github.com/${{ github.repository }}/releases/tag/$CURRENT_TAG)."; then - echo "::error::Failed to comment on issue #$issue_number" - FAILURES="$FAILURES #$issue_number" - fi - fi - done < <(echo "$ISSUE_NUMBERS" | tr ' ' '\n') - if [ -n "$FAILURES" ]; then echo "::error::Failed to update the following issue(s):$FAILURES" exit 1