@@ -118,6 +118,73 @@ $platformLabels = @{
118118 " maccatalyst" = " platform/macOS 🍏"
119119}
120120
121+ # Query current milestones dynamically to avoid hardcoding
122+ Write-Host " Fetching current milestones..." - ForegroundColor DarkGray
123+ $currentMilestones = @ {
124+ CurrentSR = " " # The soonest SR milestone (for regressions)
125+ NextSR = " " # The next SR milestone (for other important bugs)
126+ Servicing = " " # The Servicing milestone (for PRs)
127+ Backlog = " Backlog" # Always "Backlog"
128+ }
129+
130+ try {
131+ $msResult = gh api repos/ dotnet/ maui/ milestones -- jq ' .[] | {title, due_on}' 2> $null
132+ $msLines = $msResult -split " `n " | Where-Object { $_.Trim () -ne " " }
133+
134+ $srMilestones = @ ()
135+ $servicingMilestone = " "
136+
137+ foreach ($line in $msLines ) {
138+ try {
139+ $ms = $line | ConvertFrom-Json - ErrorAction Stop
140+ # Match .NET SR milestones (e.g., ".NET 10.0 SR3", ".NET 9.0 SR5")
141+ if ($ms.title -match " \.NET.*SR\d+" ) {
142+ $srMilestones += [PSCustomObject ]@ {
143+ Title = $ms.title
144+ DueOn = $ms.due_on
145+ }
146+ }
147+ # Match Servicing milestones (e.g., ".NET 10 Servicing")
148+ elseif ($ms.title -match " \.NET.*Servicing" -and $ms.title -notmatch " SR" ) {
149+ $servicingMilestone = $ms.title
150+ }
151+ }
152+ catch {
153+ # Skip lines that aren't valid JSON
154+ continue
155+ }
156+ }
157+
158+ # Sort SR milestones by due date (soonest first) or by SR number
159+ if ($srMilestones.Count -gt 0 ) {
160+ $sortedSR = $srMilestones | Sort-Object {
161+ $parsedDate = [DateTime ]::MinValue
162+ if ($_.DueOn -and [DateTime ]::TryParse($_.DueOn , [ref ]$parsedDate )) {
163+ $parsedDate
164+ } else {
165+ [DateTime ]::MaxValue
166+ }
167+ }
168+ $currentMilestones.CurrentSR = $sortedSR [0 ].Title
169+ if ($sortedSR.Count -gt 1 ) {
170+ $currentMilestones.NextSR = $sortedSR [1 ].Title
171+ } else {
172+ $currentMilestones.NextSR = $sortedSR [0 ].Title
173+ }
174+ }
175+
176+ if ($servicingMilestone ) {
177+ $currentMilestones.Servicing = $servicingMilestone
178+ }
179+
180+ Write-Host " Current SR: $ ( $currentMilestones.CurrentSR ) " - ForegroundColor DarkGray
181+ Write-Host " Next SR: $ ( $currentMilestones.NextSR ) " - ForegroundColor DarkGray
182+ Write-Host " Servicing: $ ( $currentMilestones.Servicing ) " - ForegroundColor DarkGray
183+ }
184+ catch {
185+ Write-Host " Warning: Could not fetch milestones, using defaults" - ForegroundColor Yellow
186+ }
187+
121188# Build gh issue list command arguments
122189$ghArgs = @ (
123190 " issue" , " list" ,
@@ -323,7 +390,7 @@ foreach ($issue in $issues) {
323390 }
324391
325392 # Generate milestone suggestion based on issue characteristics
326- $suggestedMilestone = " Backlog"
393+ $suggestedMilestone = $currentMilestones . Backlog
327394 $suggestionReason = " No PR, not a regression"
328395
329396 # Check if any linked PR has a milestone
@@ -340,19 +407,26 @@ foreach ($issue in $issues) {
340407 $suggestionReason = " PR already has milestone"
341408 }
342409 elseif ($isRegression ) {
343- if ($regressedIn -match " 10\.0\.0|10-preview|10-rc" ) {
344- $suggestedMilestone = " .NET 10.0 SR3"
345- $suggestionReason = " Regression in .NET 10"
410+ # Use the current (soonest) SR milestone for regressions
411+ if ($currentMilestones.CurrentSR ) {
412+ $suggestedMilestone = $currentMilestones.CurrentSR
413+ $suggestionReason = " Regression - current SR milestone"
346414 } else {
347- $suggestedMilestone = " .NET 10.0 SR4 "
348- $suggestionReason = " Regression"
415+ $suggestedMilestone = $currentMilestones .Backlog
416+ $suggestionReason = " Regression (no SR milestone found) "
349417 }
350418 }
351419 elseif ($linkedPRs.Count -gt 0 ) {
352420 $openPRs = $linkedPRs | Where-Object { $_.State -eq " OPEN" }
353421 if ($openPRs.Count -gt 0 ) {
354- $suggestedMilestone = " .NET 10 Servicing"
355- $suggestionReason = " Has open PR"
422+ # Use Servicing milestone for PRs, fallback to next SR
423+ if ($currentMilestones.Servicing ) {
424+ $suggestedMilestone = $currentMilestones.Servicing
425+ $suggestionReason = " Has open PR"
426+ } elseif ($currentMilestones.NextSR ) {
427+ $suggestedMilestone = $currentMilestones.NextSR
428+ $suggestionReason = " Has open PR"
429+ }
356430 }
357431 }
358432
0 commit comments