Skip to content

Commit fd6dd92

Browse files
SyncFileContentsSyncFileContents
authored andcommitted
Sync scripts\update-winget-manifests.ps1
1 parent 3beb7bd commit fd6dd92

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

scripts/update-winget-manifests.ps1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,15 +811,31 @@ Write-Host " Tags: $($config.tags -join ', ')" -ForegroundColor Cyan
811811
$releaseUrl = "https://api.github.com/repos/$($config.githubRepo)/releases/tags/v$Version"
812812
$downloadBaseUrl = "https://github.com/$($config.githubRepo)/releases/download/v$Version"
813813

814+
# Build headers for GitHub API requests (with optional authentication)
815+
$githubHeaders = @{
816+
"User-Agent" = "Winget-Manifest-Updater"
817+
"Accept" = "application/vnd.github.v3+json"
818+
}
819+
820+
# Check for GITHUB_TOKEN environment variable for authenticated requests (higher rate limit)
821+
$githubToken = $env:GITHUB_TOKEN
822+
if (-not $githubToken) {
823+
$githubToken = $env:GH_TOKEN
824+
}
825+
if ($githubToken) {
826+
$githubHeaders["Authorization"] = "Bearer $githubToken"
827+
Write-Host "Using authenticated GitHub API requests" -ForegroundColor Green
828+
} else {
829+
Write-Host "Warning: No GITHUB_TOKEN found. API requests may be rate-limited." -ForegroundColor Yellow
830+
Write-Host "Set GITHUB_TOKEN environment variable for authenticated requests." -ForegroundColor Yellow
831+
}
832+
814833
Write-Host "Updating winget manifests for $($config.packageName) version $Version..." -ForegroundColor Green
815834

816835
# Fetch release information from GitHub
817836
try {
818837
Write-Host "Fetching release information from GitHub..." -ForegroundColor Yellow
819-
$release = Invoke-RestMethod -Uri $releaseUrl -Headers @{
820-
"User-Agent" = "Winget-Manifest-Updater"
821-
"Accept" = "application/vnd.github.v3+json"
822-
}
838+
$release = Invoke-RestMethod -Uri $releaseUrl -Headers $githubHeaders
823839

824840
Write-Host "Found release: $($release.name)" -ForegroundColor Green
825841
$releaseDate = [DateTime]::Parse($release.published_at).ToString("yyyy-MM-dd")

0 commit comments

Comments
 (0)