@@ -276,6 +276,74 @@ jobs:
276276
277277 rm "$BODY_FILE"
278278
279+ - name : " 🧹 Close old pre-release issues for tested versions"
280+ if : steps.runtests.outputs.successful_versions != '' || steps.runtests.outputs.failed_version != ''
281+ env :
282+ REPO : ${{ github.repository }}
283+ PRE_RELEASE_SUFFIX : " (alpha[0-9]*|beta[0-9]*|rc[0-9]*|cr[0-9]*|m[0-9]+|ea[0-9]*|b[0-9]+|[0-9]+|preview)"
284+ run : |
285+ set -euo pipefail
286+ git config --local user.email "actions@github.com"
287+ git config --local user.name "Github Actions"
288+
289+ # Prepare list of versions to consider: successful versions + failed version (if any)
290+ VERSIONS_FILE=$(mktemp)
291+ if [[ -n "${{ steps.runtests.outputs.successful_versions }}" ]]; then
292+ echo "${{ steps.runtests.outputs.successful_versions }}" | tr ' ' '\n' >> "$VERSIONS_FILE"
293+ fi
294+ if [[ -n "${{ steps.runtests.outputs.failed_version }}" ]]; then
295+ echo "${{ steps.runtests.outputs.failed_version }}" >> "$VERSIONS_FILE"
296+ fi
297+
298+ while read -r VERSION; do
299+ if [[ -z "$VERSION" ]]; then continue; fi
300+
301+ # Parse version
302+ VERSION_REGEX="^([0-9]+(\.[0-9]+)*)(\.Final)?([-.]$PRE_RELEASE_SUFFIX([-.].*)?)?$"
303+ if [[ "$VERSION" =~ $VERSION_REGEX ]]; then
304+ BASE_VERSION="${BASH_REMATCH[1]}"
305+ PRE_RELEASE_TAG="${BASH_REMATCH[4]-}"
306+ else
307+ echo "Skipping invalid version: $VERSION"
308+ continue
309+ fi
310+
311+ # Only full releases trigger closing pre-release issues
312+ if [[ -n "$PRE_RELEASE_TAG" ]]; then
313+ echo "$VERSION is a pre-release, skipping issue closing."
314+ continue
315+ fi
316+
317+ PRE_RELEASE_REGEX="$BASE_VERSION[-.]$PRE_RELEASE_SUFFIX"
318+
319+ GROUP_ID="$(echo "${{ matrix.item.name }}" | cut -d: -f1)"
320+ ARTIFACT_ID="$(echo "${{ matrix.item.name }}" | cut -d: -f2)"
321+ GAV_COORDINATES_VERSIONLESS="$GROUP_ID:$ARTIFACT_ID"
322+ TITLE_END_VERSIONLESS="${{ env.ISSUE_TITLE_MIDDLE }}$GAV_COORDINATES_VERSIONLESS"
323+
324+ # Find all open pre-release issues for this library and base version
325+ PRE_RELEASE_ISSUES=$(gh issue list \
326+ --repo "$REPO" \
327+ --state open \
328+ --search "\"$TITLE_END_VERSIONLESS\" in:title" \
329+ --json number,title \
330+ --jq ".[] | select(.title | startswith(\"${{ env.ISSUE_TITLE_PREFIX }}\") and test(\"$TITLE_END_VERSIONLESS:$PRE_RELEASE_REGEX\"; \"i\")) | .number")
331+
332+ if [[ -n "$PRE_RELEASE_ISSUES" ]]; then
333+ echo "Closing pre-release issues for ${{ matrix.item.name }} version $BASE_VERSION:"
334+ for ISSUE in $PRE_RELEASE_ISSUES; do
335+ echo "Closing issue #$ISSUE"
336+ gh issue close "$ISSUE" --repo "$REPO" \
337+ -c "Closing this pre-release issue because a full release is now available and/or builds successfully." \
338+ -r "not planned"
339+ done
340+ else
341+ echo "No pre-release issues found for ${{ matrix.item.name }} version $BASE_VERSION"
342+ fi
343+ done < "$VERSIONS_FILE"
344+
345+ rm "$VERSIONS_FILE"
346+
279347 process-results :
280348 name : " 🧪 Process results"
281349 runs-on : ubuntu-22.04
0 commit comments