5151 -H "Accept : application/vnd.github+json" \
5252 -H "Authorization : Bearer $GITHUB_TOKEN" \
5353 -H "X-GitHub-Api-Version : 2022-11-28" \
54- https://api.github.com/repos/PowerShell/PowerShell/releases |
54+ ' https://api.github.com/repos/PowerShell/PowerShell/releases?per_page=100 ' |
5555 jq -r '[.[] | select(.prerelease == true)] | (.[0].tag_name // empty)' | sed 's/^v//'
5656 )
5757 if [[ -z "$REQUESTED_VERSION" ]]; then
@@ -128,10 +128,14 @@ runs:
128128 # `shell: pwsh` steps resolve to the version we just installed.
129129 if [[ "$REQUESTED_VERSION" == *-* ]]; then
130130 MAJOR_VERSION=$(echo "$REQUESTED_VERSION" | cut -d'.' -f1)
131- INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}-preview"
132- if [[ -d "$INSTALL_DIR" ]]; then
133- echo "Adding install directory to GITHUB_PATH : $INSTALL_DIR"
134- echo "$INSTALL_DIR" >> "$GITHUB_PATH"
131+ if [[ "$MAJOR_VERSION" =~ ^[0-9]+$ ]]; then
132+ INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}-preview"
133+ if [[ -d "$INSTALL_DIR" ]]; then
134+ echo "Adding install directory to GITHUB_PATH : $INSTALL_DIR"
135+ echo "$INSTALL_DIR" >> "$GITHUB_PATH"
136+ fi
137+ else
138+ echo "Warning : Computed MAJOR_VERSION ('$MAJOR_VERSION') is invalid; skipping GITHUB_PATH update." >&2
135139 fi
136140 fi
137141
@@ -159,7 +163,7 @@ runs:
159163 -H "Accept : application/vnd.github+json" \
160164 -H "Authorization : Bearer $GITHUB_TOKEN" \
161165 -H "X-GitHub-Api-Version : 2022-11-28" \
162- https://api.github.com/repos/PowerShell/PowerShell/releases |
166+ ' https://api.github.com/repos/PowerShell/PowerShell/releases?per_page=100 ' |
163167 jq -r '[.[] | select(.prerelease == true)] | (.[0].tag_name // empty)' | sed 's/^v//'
164168 )
165169 if [[ -z "$REQUESTED_VERSION" ]]; then
@@ -223,10 +227,14 @@ runs:
223227 # `shell: pwsh` steps resolve to the version we just installed.
224228 if [[ "$REQUESTED_VERSION" == *-* ]]; then
225229 MAJOR_VERSION=$(echo "$REQUESTED_VERSION" | cut -d'.' -f1)
226- INSTALL_DIR="/usr/local/microsoft/powershell/${MAJOR_VERSION}-preview"
227- if [[ -d "$INSTALL_DIR" ]]; then
228- echo "Adding install directory to GITHUB_PATH : $INSTALL_DIR"
229- echo "$INSTALL_DIR" >> "$GITHUB_PATH"
230+ if [[ "$MAJOR_VERSION" =~ ^[0-9]+$ ]]; then
231+ INSTALL_DIR="/usr/local/microsoft/powershell/${MAJOR_VERSION}-preview"
232+ if [[ -d "$INSTALL_DIR" ]]; then
233+ echo "Adding install directory to GITHUB_PATH : $INSTALL_DIR"
234+ echo "$INSTALL_DIR" >> "$GITHUB_PATH"
235+ fi
236+ else
237+ echo "Warning : Computed MAJOR_VERSION ('$MAJOR_VERSION') is invalid; skipping GITHUB_PATH update." >&2
230238 fi
231239 fi
232240
@@ -253,7 +261,7 @@ runs:
253261 ' X-GitHub-Api-Version' = '2022-11-28'
254262 }
255263 if ($env:PRERELEASE -eq 'true') {
256- $releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases' -Headers $headers
264+ $releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases?per_page=100 ' -Headers $headers
257265 $latestRelease = $releases | Where-Object { $_.prerelease -eq $true } | Select-Object -First 1
258266 if (-not $latestRelease) {
259267 Write-Host "Error : No prerelease PowerShell releases are available from GitHub."
@@ -390,14 +398,18 @@ runs:
390398 # install directory (7-preview) is not on the runner's default PATH.
391399 $isPrerelease = $env:REQUESTED_VERSION -match '-'
392400 $majorVersion = ($env:REQUESTED_VERSION -split '[.\-]')[0]
393- $installDir = if ($isPrerelease) {
394- " $env:ProgramFiles\P owerShell\$ majorVersion-preview"
395- } else {
396- " $env:ProgramFiles\P owerShell\$ majorVersion"
397- }
398- if (Test-Path $installDir) {
399- Write-Host "Adding install directory to GITHUB_PATH : $installDir"
400- Add-Content -Path $env:GITHUB_PATH -Value $installDir
401+ if ($majorVersion -match '^\d+$') {
402+ $installDir = if ($isPrerelease) {
403+ " $env:ProgramFiles\P owerShell\$ majorVersion-preview"
404+ } else {
405+ " $env:ProgramFiles\P owerShell\$ majorVersion"
406+ }
407+ if (Test-Path $installDir) {
408+ Write-Host "Adding install directory to GITHUB_PATH : $installDir"
409+ Add-Content -Path $env:GITHUB_PATH -Value $installDir
410+ } else {
411+ Write-Host "Warning : Expected install directory not found: $installDir"
412+ }
401413 } else {
402- Write-Host "Warning : Expected install directory not found: $installDir "
414+ Write-Host "Warning : Computed major version ('$majorVersion') is invalid; skipping GITHUB_PATH update. "
403415 }
0 commit comments