generated from PSModule/Template-Action
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
491 lines (450 loc) · 23.2 KB
/
action.yml
File metadata and controls
491 lines (450 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
name: Install PowerShell
description: |
Install a specific version, or the latest stable version, of PowerShell Core
on any GitHub runner (Linux, macOS, Windows).
Skips the install if the requested version is already present.
author: PSModule
branding:
icon: terminal
color: purple
inputs:
Version:
description: |
PowerShell version to install (e.g. `7.4.1` or `7.4.0-preview.5`).
Defaults to install the latest stable release.
Prerelease versions are supported (e.g. `7.4.0-preview.5`, `7.5.0-rc.1`).
required: false
default: 'latest'
Prerelease:
description: |
Install a prerelease version of PowerShell.
When `true` and `Version` is `latest`, installs the latest prerelease.
Similar to the `-Prerelease` switch on `Install-PSResource`.
required: false
default: 'false'
runs:
using: composite
steps:
- name: Install PowerShell (Linux)
if: runner.os == 'Linux'
shell: bash
working-directory: ${{ github.action_path }}
env:
REQUESTED_VERSION: ${{ inputs.Version }}
PRERELEASE: ${{ inputs.Prerelease }}
GITHUB_TOKEN: ${{ github.token }}
run:
| # zizmor: ignore[github-env] GITHUB_PATH writes use hardcoded install dirs, not user input
# Install-PowerShell
set -e
echo "Requested version: [$REQUESTED_VERSION]"
echo "Prerelease: [$PRERELEASE]"
# Only resolve to latest version if explicitly set to 'latest' (case-insensitive)
case "${REQUESTED_VERSION:-}" in
[Ll][Aa][Tt][Ee][Ss][Tt])
if [[ "$PRERELEASE" == "true" ]]; then
REQUESTED_VERSION=$(
curl -s -f \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
'https://api.github.com/repos/PowerShell/PowerShell/releases?per_page=100' |
jq -r '[.[] | select(.prerelease == true)] | (.[0].tag_name // empty)' | sed 's/^v//'
)
if [[ -z "$REQUESTED_VERSION" ]]; then
echo "Error: No prerelease PowerShell releases found when resolving latest prerelease."
exit 1
fi
echo "Latest prerelease PowerShell version detected: $REQUESTED_VERSION"
else
REQUESTED_VERSION=$(
curl -s -f \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
jq -r '.tag_name' | sed 's/^v//'
)
if [[ -z "$REQUESTED_VERSION" ]]; then
echo "Error: Failed to resolve latest stable PowerShell release from GitHub."
exit 1
fi
echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
fi
;;
"")
echo "Error: Version input is required (or use 'latest')"
exit 1
;;
esac
DETECTED_VERSION=$(pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' 2>/dev/null || true)
if [[ -n "$DETECTED_VERSION" ]]; then
echo "Currently installed PowerShell version: $DETECTED_VERSION"
else
echo "PowerShell is not currently installed"
fi
if [[ "$DETECTED_VERSION" == "$REQUESTED_VERSION" ]]; then
echo "PowerShell $DETECTED_VERSION already installed. Skipping."
exit 0
fi
# Determine Linux distribution type
ARCH=$(dpkg --print-architecture 2>/dev/null || rpm --eval '%{_arch}' 2>/dev/null || echo "x86_64")
# Query GitHub Releases API for the actual asset URLs to handle naming
# convention differences across releases (e.g. powershell-preview_ vs powershell_).
RELEASE_JSON=$(
curl -s -f \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/PowerShell/PowerShell/releases/tags/v${REQUESTED_VERSION}"
)
if [[ -z "$RELEASE_JSON" ]]; then
echo "Error: Failed to fetch release info for v${REQUESTED_VERSION} from GitHub."
exit 1
fi
# Determine if the requested version is a prerelease (contains a hyphen, e.g. 7.6.0-preview.6)
IS_PRERELEASE=false
if [[ "$REQUESTED_VERSION" == *-* ]]; then
IS_PRERELEASE=true
fi
if command -v apt-get >/dev/null || command -v dpkg >/dev/null; then
# Debian/Ubuntu based
echo "Detected Debian/Ubuntu based system..."
if [[ "$IS_PRERELEASE" == "true" ]]; then
# Prerelease .deb naming varies across releases:
# Older: powershell-preview_7.4.0-preview.5-1.deb_amd64.deb
# Newer: powershell_7.6.0-preview.6-1.deb_amd64.deb
# Try powershell-preview_ first, then fall back to powershell_
URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
'[.assets[] | select(.name | test("^powershell-preview_.*\\.deb_" + $arch + "\\.deb$"))] | .[0].browser_download_url // empty')
if [[ -z "$URL" ]]; then
URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
'[.assets[] | select(.name | test("^powershell_.*\\.deb_" + $arch + "\\.deb$"))] | .[0].browser_download_url // empty')
fi
else
# For stable versions, select the powershell package (not powershell-lts or powershell-preview)
URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
'[.assets[] | select(.name | test("^powershell_.*\\.deb_" + $arch + "\\.deb$"))] | .[0].browser_download_url // empty')
fi
if [[ -z "$URL" ]]; then
echo "Error: No .deb package found for architecture '$ARCH' in release v${REQUESTED_VERSION}."
exit 1
fi
DEB_NAME=$(basename "$URL")
echo "Downloading from: $URL"
wget -q "$URL" -O "$DEB_NAME"
# Remove all existing PowerShell packages to avoid dpkg conflicts
# (powershell, powershell-lts, and powershell-preview all provide /usr/bin/pwsh)
echo "Removing existing PowerShell packages to avoid conflicts..."
sudo dpkg --remove powershell powershell-lts powershell-preview 2>/dev/null || true
echo "Starting installation of PowerShell [$REQUESTED_VERSION]..."
sudo dpkg -i "$DEB_NAME" || sudo apt-get -f install -y
elif command -v rpm >/dev/null; then
# RHEL/Fedora/CentOS based
echo "Detected RHEL/Fedora/CentOS based system..."
if [[ "$IS_PRERELEASE" == "true" ]]; then
# Prerelease .rpm naming varies across releases:
# Older: powershell-preview-7.4.0_preview.5-1.rh.x86_64.rpm
# Newer: powershell-7.6.0_preview.6-1.rh.x86_64.rpm
# Try powershell-preview first, then fall back to powershell-<version>
URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
'[.assets[] | select(.name | test("^powershell-preview.*\\.rh\\." + (if $arch == "aarch64" then $arch else "x86_64" end) + "\\.rpm$"))] | .[0].browser_download_url // empty')
if [[ -z "$URL" ]]; then
URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
'[.assets[] | select(.name | test("^powershell-[0-9].*\\.rh\\." + (if $arch == "aarch64" then $arch else "x86_64" end) + "\\.rpm$"))] | .[0].browser_download_url // empty')
fi
else
URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
'[.assets[] | select(.name | test("^powershell-[0-9].*\\.rh\\." + (if $arch == "aarch64" then $arch else "x86_64" end) + "\\.rpm$"))] | .[0].browser_download_url // empty')
fi
if [[ -z "$URL" ]]; then
echo "Error: No .rpm package found for architecture '$ARCH' in release v${REQUESTED_VERSION}."
exit 1
fi
RPM_NAME=$(basename "$URL")
echo "Downloading from: $URL"
wget -q "$URL" -O "$RPM_NAME"
# Remove existing PowerShell packages to avoid conflicts
echo "Removing existing PowerShell packages to avoid conflicts..."
sudo rpm -e powershell powershell-preview 2>/dev/null || true
echo "Starting installation of PowerShell [$REQUESTED_VERSION]..."
sudo rpm -i "$RPM_NAME" || sudo yum install -y "$RPM_NAME"
else
echo "Unsupported Linux distribution. Cannot determine package format."
exit 1
fi
# Determine the install directory and add to PATH before verification.
# Preview builds install to /opt/microsoft/powershell/<major>-preview/
# which is not on the default PATH after removing the old powershell package.
MAJOR_VERSION=$(echo "$REQUESTED_VERSION" | cut -d'.' -f1)
if [[ "$IS_PRERELEASE" == "true" ]]; then
INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}-preview"
else
INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}"
fi
if [[ -d "$INSTALL_DIR" ]]; then
export PATH="$INSTALL_DIR:$PATH"
fi
# Verify installation succeeded
INSTALLED_VERSION=$(pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' 2>/dev/null || true)
if [[ "$INSTALLED_VERSION" != "$REQUESTED_VERSION" ]]; then
echo "Error: Installation verification failed. Expected $REQUESTED_VERSION but got ${INSTALLED_VERSION:-nothing}."
exit 1
fi
echo "Installation complete. PowerShell [$REQUESTED_VERSION] is now available."
# For prerelease builds, add the install directory to GITHUB_PATH so subsequent
# `shell: pwsh` steps resolve to the version we just installed.
if [[ "$IS_PRERELEASE" == "true" && -d "$INSTALL_DIR" ]]; then
echo "Adding install directory to GITHUB_PATH: $INSTALL_DIR"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
fi
- name: Install PowerShell (macOS)
if: runner.os == 'macOS'
shell: bash
working-directory: ${{ github.action_path }}
env:
REQUESTED_VERSION: ${{ inputs.Version }}
PRERELEASE: ${{ inputs.Prerelease }}
GITHUB_TOKEN: ${{ github.token }}
run:
| # zizmor: ignore[github-env] GITHUB_PATH writes use hardcoded install dirs, not user input
# Install-PowerShell
set -e
echo "Requested version: [$REQUESTED_VERSION]"
echo "Prerelease: [$PRERELEASE]"
# Only resolve to latest version if explicitly set to 'latest' (case-insensitive)
case "${REQUESTED_VERSION:-}" in
[Ll][Aa][Tt][Ee][Ss][Tt])
if [[ "$PRERELEASE" == "true" ]]; then
REQUESTED_VERSION=$(
curl -s -f \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
'https://api.github.com/repos/PowerShell/PowerShell/releases?per_page=100' |
jq -r '[.[] | select(.prerelease == true)] | (.[0].tag_name // empty)' | sed 's/^v//'
)
if [[ -z "$REQUESTED_VERSION" ]]; then
echo "Error: No prerelease PowerShell releases found when resolving latest prerelease."
exit 1
fi
echo "Latest prerelease PowerShell version detected: $REQUESTED_VERSION"
else
REQUESTED_VERSION=$(
curl -s -f \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
jq -r '.tag_name' | sed 's/^v//'
)
if [[ -z "$REQUESTED_VERSION" ]]; then
echo "Error: Failed to resolve latest stable PowerShell release from GitHub."
exit 1
fi
echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
fi
;;
"")
echo "Error: Version input is required (or use 'latest')"
exit 1
;;
esac
DETECTED_VERSION=$(pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' 2>/dev/null || true)
if [[ -n "$DETECTED_VERSION" ]]; then
echo "Currently installed PowerShell version: $DETECTED_VERSION"
else
echo "PowerShell is not currently installed"
fi
if [[ "$DETECTED_VERSION" == "$REQUESTED_VERSION" ]]; then
echo "PowerShell $DETECTED_VERSION already installed. Skipping."
exit 0
fi
# Determine architecture and download appropriate package
ARCH=$(uname -m)
case "$ARCH" in
"arm64") PKG_NAME="powershell-${REQUESTED_VERSION}-osx-arm64.pkg" ;;
*) PKG_NAME="powershell-${REQUESTED_VERSION}-osx-x64.pkg" ;;
esac
URL="https://github.com/PowerShell/PowerShell/releases/download/v${REQUESTED_VERSION}/${PKG_NAME}"
echo "Downloading from: $URL"
echo "Starting installation of PowerShell [$REQUESTED_VERSION]..."
if ! curl -sSL "$URL" -o "$PKG_NAME"; then
echo "Error: Failed to download PowerShell package"
exit 1
fi
sudo installer -pkg "$PKG_NAME" -target /
echo "Installation complete. PowerShell [$REQUESTED_VERSION] is now available."
# For prerelease builds, add the install directory to GITHUB_PATH so subsequent
# `shell: pwsh` steps resolve to the version we just installed.
if [[ "$REQUESTED_VERSION" == *-* ]]; then
MAJOR_VERSION=$(echo "$REQUESTED_VERSION" | cut -d'.' -f1)
if [[ "$MAJOR_VERSION" =~ ^[0-9]+$ ]]; then
INSTALL_DIR="/usr/local/microsoft/powershell/${MAJOR_VERSION}-preview"
if [[ -d "$INSTALL_DIR" ]]; then
echo "Adding install directory to GITHUB_PATH: $INSTALL_DIR"
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
fi
else
echo "Warning: Computed MAJOR_VERSION ('$MAJOR_VERSION') is invalid; skipping GITHUB_PATH update." >&2
fi
fi
- name: Install PowerShell (Windows)
if: runner.os == 'Windows'
shell: powershell
working-directory: ${{ github.action_path }}
env:
REQUESTED_VERSION: ${{ inputs.Version }}
PRERELEASE: ${{ inputs.Prerelease }}
GITHUB_TOKEN: ${{ github.token }}
run:
| # zizmor: ignore[github-env] GITHUB_PATH writes use hardcoded install dirs, not user input
# Install-PowerShell
Write-Host "Requested version: [$env:REQUESTED_VERSION]"
Write-Host "Prerelease: [$env:PRERELEASE]"
# Resolve 'latest' → concrete version
$req = $env:REQUESTED_VERSION
if ($req -and $req.Trim().ToLower() -eq 'latest') {
$headers = @{
'Accept' = 'application/vnd.github+json'
'Authorization' = "Bearer $($env:GITHUB_TOKEN)"
'X-GitHub-Api-Version' = '2022-11-28'
}
if ($env:PRERELEASE -eq 'true') {
$releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases?per_page=100' -Headers $headers
$latestRelease = $releases | Where-Object { $_.prerelease -eq $true } | Select-Object -First 1
if (-not $latestRelease) {
Write-Host "Error: No prerelease PowerShell releases are available from GitHub."
exit 1
}
$latest = $latestRelease.tag_name.TrimStart('v')
Write-Host "Latest prerelease PowerShell version detected: $latest"
} else {
$latest = (Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' -Headers $headers).tag_name.TrimStart('v')
if (-not $latest) {
Write-Host "Error: Failed to resolve latest stable PowerShell release from GitHub."
exit 1
}
Write-Host "Latest stable PowerShell release detected: $latest"
}
$env:REQUESTED_VERSION = $latest
} elseif ([string]::IsNullOrWhiteSpace($req)) {
Write-Host "Error: Version input is required (or use 'latest')"
exit 1
}
# Detect currently installed version (if any)
$detected = $null
try {
$detected = (pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
Write-Host "Currently installed PowerShell version: $detected"
} catch {
Write-Host "PowerShell is not currently installed"
}
if ($detected -eq $env:REQUESTED_VERSION) {
Write-Host "PowerShell $detected already installed. Skipping."
exit 0
}
# Downgrade detection
# Strip prerelease suffix for [version] comparison (e.g. '7.6.0-preview.6' → '7.6.0')
$isDowngrade = $false
if ($detected -and $detected -ne $env:REQUESTED_VERSION) {
try {
$detectedBase = ($detected -split '-')[0]
$requestedBase = ($env:REQUESTED_VERSION -split '-')[0]
$detectedVersion = [version]$detectedBase
$requestedVersion = [version]$requestedBase
if ($detectedVersion -gt $requestedVersion) {
Write-Host "Downgrade detected: $detected → $($env:REQUESTED_VERSION)"
$isDowngrade = $true
} elseif ($detectedVersion -eq $requestedVersion -and $detected -ne $env:REQUESTED_VERSION) {
# Same base version but different prerelease label — MSI installers cannot
# handle cross-prerelease changes in-place, so force uninstall first.
Write-Host "Prerelease version change detected (same base, different label): $detected → $($env:REQUESTED_VERSION)"
$isDowngrade = $true
} else {
Write-Host "Upgrade detected: $detected → $($env:REQUESTED_VERSION)"
}
} catch {
Write-Host "Warning: Could not compare versions, proceeding with regular installation"
}
}
# If downgrade → fully uninstall current PowerShell 7
if ($isDowngrade) {
Write-Host "Uninstalling existing PowerShell version before downgrade..."
# Search both 64-bit and 32-bit uninstall hives
$regPaths = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$isDetectedPreview = $detected -match '-preview|-rc'
$pwshEntries = Get-ItemProperty -Path $regPaths -ErrorAction SilentlyContinue |
Where-Object {
$_.Publisher -eq 'Microsoft Corporation' -and
$_.DisplayName -like 'PowerShell 7*' -and
$(if ($isDetectedPreview) { $_.DisplayName -like '*Preview*' } else { $_.DisplayName -notlike '*Preview*' }) -and
$_.DisplayVersion -and
($_.DisplayVersion -match "^$([regex]::Escape(($detected -split '-')[0]))([.\-]|$)" -or $_.DisplayVersion -eq ($detected -split '-')[0])
}
$targetEntry = $pwshEntries | Select-Object -First 1
if (-not $targetEntry) {
Write-Host "Warning: Could not find an uninstall entry for PowerShell $detected"
} else {
$uninstallCmd = if ($targetEntry.QuietUninstallString) {
$targetEntry.QuietUninstallString
} else {
$targetEntry.UninstallString
}
# If the uninstall command is MSI-based and lacks /quiet, add it
if ($uninstallCmd -match 'msiexec') {
if ($uninstallCmd -notmatch '/quiet') { $uninstallCmd += ' /quiet' }
if ($uninstallCmd -notmatch '/norestart') { $uninstallCmd += ' /norestart' }
}
Write-Host "Running uninstall command:`n$uninstallCmd"
$proc = Start-Process 'cmd.exe' -ArgumentList '/c', $uninstallCmd -Wait -PassThru
if ($proc.ExitCode -ne 0) {
Write-Host "Error: Uninstall failed (exit code $($proc.ExitCode))."
exit 1
}
# Double-check removal
try {
$after = (pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
if ($after) {
Write-Host "Error: PowerShell is still present ($after) after uninstall. Aborting downgrade."
exit 1
}
} catch { }
}
}
# Download requested MSI
$msi = "PowerShell-$($env:REQUESTED_VERSION)-win-x64.msi"
$url = "https://github.com/PowerShell/PowerShell/releases/download/v$($env:REQUESTED_VERSION)/$msi"
Write-Host "Downloading from: $url"
$null = Invoke-WebRequest -Uri $url -OutFile $msi -UseBasicParsing -ErrorAction Stop
# Install requested version
Write-Host "Starting installation of PowerShell [$($env:REQUESTED_VERSION)]..."
$msiProcess = Start-Process msiexec.exe -ArgumentList '/i', $msi, '/quiet', '/norestart' -Wait -PassThru
if ($msiProcess.ExitCode -ne 0) {
Write-Host "Error: Installation failed (exit code $($msiProcess.ExitCode))."
exit 1
}
Write-Host "Installation complete. PowerShell [$($env:REQUESTED_VERSION)] is now available."
# Add the install directory to GITHUB_PATH so subsequent `shell: pwsh` steps
# resolve to the version we just installed — even for preview builds whose
# install directory (7-preview) is not on the runner's default PATH.
$isPrerelease = $env:REQUESTED_VERSION -match '-'
$majorVersion = ($env:REQUESTED_VERSION -split '[.\-]')[0]
if ($majorVersion -match '^\d+$') {
$installDir = if ($isPrerelease) {
"$env:ProgramFiles\PowerShell\$majorVersion-preview"
} else {
"$env:ProgramFiles\PowerShell\$majorVersion"
}
if (Test-Path $installDir) {
Write-Host "Adding install directory to GITHUB_PATH: $installDir"
Add-Content -Path $env:GITHUB_PATH -Value $installDir
} else {
Write-Host "Warning: Expected install directory not found: $installDir"
}
} else {
Write-Host "Warning: Computed major version ('$majorVersion') is invalid; skipping GITHUB_PATH update."
}