Skip to content
Merged
Changes from all commits
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
20 changes: 14 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on merged PRs
- name: Label and comment on merged PRs
if: steps.version.outputs.skip != 'true'
run: |
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
NEW_VERSION="${{ steps.version.outputs.new_version }}"

# Ensure "released" label exists
gh label create "released" --color "9ab87c" --description "Included in a release" 2>/dev/null || true

# Get PR numbers from commits since last tag
if [ "$LATEST_TAG" = "v0.0.0" ]; then
COMMITS=$(git log --pretty=format:"%H" HEAD)
Expand All @@ -187,17 +190,22 @@ jobs:
fi

# Find PRs associated with these commits
COMMENTED_PRS=""
LABELED_PRS=""
while IFS= read -r sha; do
# Get PR number for this commit
PR_DATA=$(gh pr list --state merged --search "$sha" --json number --jq '.[0].number' 2>/dev/null || echo "")

if [ -n "$PR_DATA" ] && [ "$PR_DATA" != "null" ]; then
# Avoid duplicate comments
if [[ ! "$COMMENTED_PRS" =~ "$PR_DATA" ]]; then
# Avoid duplicate actions
if [[ ! "$LABELED_PRS" =~ "$PR_DATA" ]]; then
# Add "released" label
gh pr edit "$PR_DATA" --add-label "released" 2>/dev/null || true

# Add comment with release link
gh pr comment "$PR_DATA" --body "🚀 Released in [$NEW_VERSION](https://github.com/${{ github.repository }}/releases/tag/$NEW_VERSION)" 2>/dev/null || true
COMMENTED_PRS="${COMMENTED_PRS} ${PR_DATA}"
echo "Commented on PR #$PR_DATA"

LABELED_PRS="${LABELED_PRS} ${PR_DATA}"
echo "Labeled and commented on PR #$PR_DATA"
fi
fi
done <<< "$COMMITS"
Expand Down