fix(ci): use github API for choco release (#15897)

### What does this PR do?

Fixes the Chocolatey package update script that was failing with:
```
au_GetLatest failed
Object reference not set to an instance of an object.
```

The script was scraping the GitHub page, which recently broke. This switches to the GitHub API.

### Screenshot / video of UI

N/A

### What issues does this PR fix or reference?

Closes https://github.com/podman-desktop/podman-desktop/issues/15896

### How to test this PR?

```powershell
# Install au if not already
choco install au -y

# Run script
cd .chocolatey/podman-desktop
$env:VERSION = "1.25.0"
./update.ps1

# Expect nuspec & releaseNotes to be updated
```

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
This commit is contained in:
Charlie Drage 2026-01-29 12:38:58 -05:00 committed by GitHub
parent 294d6207ab
commit 60140cbf26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
import-module au
$version = $env:VERSION
$releases = 'https://github.com/containers/podman-desktop/releases/expanded_assets/v' + $version
$apiUrl = 'https://api.github.com/repos/containers/podman-desktop/releases/tags/' + 'v' + $version
function global:au_SearchReplace {
@{
@ -17,15 +17,21 @@ function global:au_SearchReplace {
}
function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases
$release = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'PowerShell' }
$url64 = $download_page.links | ? href -match '-setup.exe$' | % href | select -First 1
$version = (Split-Path ( Split-Path $url64 ) -Leaf).Substring(1)
$asset = $release.assets | Where-Object { $_.name -match '-setup\.exe$' } | Select-Object -First 1
if (-not $asset) {
throw "no -setup.exe asset found for $version"
}
$url64 = $asset.browser_download_url
$releaseNotes = $release.html_url
@{
URL64 = 'https://github.com' + $url64
URL64 = $url64
Version = $version
ReleaseNotes = $releases
ReleaseNotes = $releaseNotes
}
}