@@ -76,22 +76,26 @@ jobs:
7676 # For PRs, detect which versions were added or modified using GitHub API
7777 echo "Detecting versions changed in PR #${{ github.event.pull_request.number }}"
7878
79- # Get the diff from GitHub API using curl
80- PATCH=$(curl -s -H "Authorization: token ${{ github.token }}" \
79+ # Get the list of changed files first
80+ echo "Fetching changed files from PR..."
81+ CHANGED_FILES=$(curl -s -H "Authorization: token ${{ github.token }}" \
8182 -H "Accept: application/vnd.github.v3+json" \
8283 "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
83- jq -r '.[] | select( .filename == "releases.properties") | .patch' 2>/dev/null || echo "" )
84+ jq -r '.[].filename' )
8485
85- if [ -z "$PATCH" ]; then
86- echo "No changes to releases.properties detected"
87- echo "Testing latest 5 versions as fallback"
88- VERSIONS=$(grep -E "^[0-9]+\.[0-9]+" releases.properties | \
89- cut -d'=' -f1 | \
90- tr -d ' ' | \
91- sort -V -r | \
92- head -5 | \
93- jq -R -s -c 'split("\n") | map(select(length > 0)) | unique')
94- else
86+ echo "Changed files in PR:"
87+ echo "$CHANGED_FILES"
88+
89+ # Check if releases.properties was changed
90+ if echo "$CHANGED_FILES" | grep -q "^releases.properties$"; then
91+ echo "releases.properties was modified in this PR"
92+
93+ # Get the diff from GitHub API using curl
94+ PATCH=$(curl -s -H "Authorization: token ${{ github.token }}" \
95+ -H "Accept: application/vnd.github.v3+json" \
96+ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
97+ jq -r '.[] | select(.filename == "releases.properties") | .patch')
98+
9599 echo "Analyzing diff for added/modified versions..."
96100
97101 # Extract ALL added lines (lines starting with +) that contain version numbers
@@ -102,10 +106,10 @@ jobs:
102106 grep -E "^\+[0-9]+\.[0-9]+" | \
103107 sed 's/^+//' | \
104108 cut -d'=' -f1 | \
105- tr -d ' ' || echo "" )
109+ tr -d ' ')
106110
107111 if [ -z "$CHANGED_VERSIONS" ]; then
108- echo "No version changes found in PR "
112+ echo "No new versions found in releases.properties changes "
109113 echo "Testing latest 5 versions as fallback"
110114 VERSIONS=$(grep -E "^[0-9]+\.[0-9]+" releases.properties | \
111115 cut -d'=' -f1 | \
@@ -118,14 +122,20 @@ jobs:
118122 echo "$CHANGED_VERSIONS"
119123 VERSIONS=$(echo "$CHANGED_VERSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0)) | unique')
120124 fi
125+ else
126+ echo "releases.properties was NOT modified in this PR"
127+ echo "Skipping tests - no versions to test"
128+ VERSIONS="[]"
121129 fi
122130 else
123131 # For other events, test latest 5 versions
124132 echo "Testing latest 5 versions"
125133 VERSIONS=$(grep -E "^[0-9]+\.[0-9]+" releases.properties | \
126134 cut -d'=' -f1 | \
127135 tr -d ' ' | \
128- jq -R -s -c 'split("\n") | map(select(length > 0)) | unique | sort_by(split(".") | map(tonumber)) | reverse | .[0:5]')
136+ sort -V -r | \
137+ head -5 | \
138+ jq -R -s -c 'split("\n") | map(select(length > 0)) | unique')
129139 fi
130140
131141 echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
0 commit comments