Skip to content

Commit d01ab39

Browse files
CopilotDRSDavidSoft
andcommitted
Fix pre-release filtering for archive downloads
Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
1 parent a513d08 commit d01ab39

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

scripts/update.ps1

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,39 @@ function Fetch-DownloadUrl {
196196

197197
# Special case for archive downloads of repository
198198
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
199-
if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive") -and $info[0].tag_name) {
200-
for ($i = 0; $i -lt $p.Length; $i++) {
201-
if ($p[$i].Trim('/') -eq "archive") {
202-
$p[$i + 1] = $info[0].tag_name + ".zip"
203-
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
204-
return $downloadLinks
199+
if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive")) {
200+
# Find the first release that matches our pre-release filtering criteria
201+
$selectedRelease = $null
202+
foreach ($release in $info) {
203+
# Apply the same filtering logic
204+
if (-not $includePrerelease) {
205+
if ($release.prerelease -eq $true) {
206+
continue
207+
}
208+
$prereleaseKeywords = @('-rc', '-beta', '-alpha', '-preview', '-pre')
209+
$isPrerelease = $false
210+
foreach ($keyword in $prereleaseKeywords) {
211+
if ($release.tag_name -ilike "*$keyword*") {
212+
$isPrerelease = $true
213+
break
214+
}
215+
}
216+
if ($isPrerelease) {
217+
continue
218+
}
219+
}
220+
# Use the first release that passes the filter
221+
$selectedRelease = $release
222+
break
223+
}
224+
225+
if ($selectedRelease -and $selectedRelease.tag_name) {
226+
for ($i = 0; $i -lt $p.Length; $i++) {
227+
if ($p[$i].Trim('/') -eq "archive") {
228+
$p[$i + 1] = $selectedRelease.tag_name + ".zip"
229+
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
230+
return $downloadLinks
231+
}
205232
}
206233
}
207234
}

0 commit comments

Comments
 (0)