1+ # Set the package ID based on the release info
2+ $packageId = if (' ${{ !github.event.release.prerelease }}' -eq ' true' ) { ' GitHub.Copilot' } else { ' GitHub.Copilot.Prerelease' }
3+
4+ # Get installer info from release event
5+ $assets = ' ${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
6+ $packageVersion = (${{ toJSON(github.event.release.tag_name) } })
7+
8+ # Find the download URLs for the x64 and arm64 installers separately
9+ # This allows overrides to be used so that wingetcreate does not have to guess the architecture from the filename
10+ $installerUrlx64 = $assets | Where-Object - Property name -like ' *win32-x64.zip' | Select-Object - ExpandProperty browser_download_url
11+ $installerUrlarm64 = $assets | Where-Object - Property name -like ' *win32-arm64.zip' | Select-Object - ExpandProperty browser_download_url
12+
13+ # Update package using wingetcreate
14+ curl.exe - JLO https:// aka.ms/ wingetcreate/ latest
15+ .\wingetcreate.exe update $packageId `
16+ -- version $packageVersion `
17+ -- urls " $installerUrlx64 |x64" " $installerUrlarm64 |arm64" `
18+ -- out manifests
19+
20+ # Add PowerShell dependency to installer manifest
21+ $installerManifest = Get-ChildItem - Path manifests - Filter " *.installer.yaml" - Recurse | Select-Object - First 1 - ExpandProperty FullName
22+ if (-not $installerManifest ) {
23+ Write-Error " No installer manifest (*.installer.yaml) was found in the 'manifests' directory."
24+ exit 1
25+ }
26+ $content = Get-Content - Path $installerManifest - Raw
27+ $dependency = @"
28+ Dependencies:
29+ PackageDependencies:
30+ - PackageIdentifier: Microsoft.PowerShell
31+ MinimumVersion: "7.0.0"
32+ "@
33+ # Remove existing top-level Dependencies block (if any), then insert ours
34+ $content = $content -replace '(?m)^Dependencies:\r?\n([ ]+.+\r?\n)*', ''
35+ $content = $content -replace '(?m)^Installers:', "$dependency `n Installers:"
36+ Set-Content -Path $installerManifest -Value $content
37+
38+ # Submit the modified manifest
39+ $manifestPath = Split-Path $installerManifest
40+ .\wingetcreate.exe submit $manifestPath
0 commit comments