@@ -12,10 +12,9 @@ inputs:
1212 Version :
1313 description : >
1414 PowerShell version to install (e.g. `7.4.1`).
15- Use `latest`, `null`, leave it **empty**, or omit the input entirely
16- to grab the newest stable release automatically.
15+ Set to 'latest' to automatically install the newest stable release.
1716 required : false
18- default : ' ' # Empty string → newest release
17+ default : ' latest '
1918
2019runs :
2120 using : composite
@@ -30,16 +29,20 @@ runs:
3029
3130 echo "Requested version: [$REQUESTED_VERSION]"
3231
33- # Resolve "" / null / latest → concrete latest version (Bash‑3 safe )
32+ # Only resolve to latest version if explicitly set to ' latest' (case-insensitive )
3433 case "${REQUESTED_VERSION:-}" in
35- ""| [Ll][Aa][Tt][Ee][Ss][Tt]|[Nn][Uu][Ll][Ll]|~ )
34+ [Ll][Aa][Tt][Ee][Ss][Tt])
3635 REQUESTED_VERSION=$(
3736 curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
3837 grep '"tag_name"' | head -n1 |
3938 sed -E 's/.*"v?([^"]+)".*/\1/'
4039 )
4140 echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
4241 ;;
42+ "")
43+ echo "Error: Version input is required (or use 'latest')"
44+ exit 1
45+ ;;
4346 esac
4447
4548 DETECTED_VERSION=$(pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' 2>/dev/null || true)
@@ -87,19 +90,16 @@ runs:
8790
8891 echo "Requested version: [$REQUESTED_VERSION]"
8992
90- # Resolve "" / null / latest → concrete latest version
91- if [[ -z "${REQUESTED_VERSION}" || "${REQUESTED_VERSION}" =~ ^[Ll][Aa][Tt][Ee][Ss][Tt]$ || "${REQUESTED_VERSION}" =~ ^[Nn][Uu][Ll][Ll]$ || "${REQUESTED_VERSION}" == "~" ]]; then
93+ # Only resolve to latest version if explicitly set to ' latest' (case-insensitive)
94+ if [[ "${REQUESTED_VERSION}" =~ ^[Ll][Aa][Tt][Ee][Ss][Tt]$ ]]; then
9295 REQUESTED_VERSION=$(
9396 curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
9497 grep '"tag_name"' | head -n1 |
9598 sed -E 's/.*"v?([^"]+)".*/\1/'
9699 )
97100 echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
98- fi
99-
100- # Validate REQUESTED_VERSION is not empty
101- if [[ -z "${REQUESTED_VERSION}" ]]; then
102- echo "Error: Could not determine a valid PowerShell version."
101+ elif [[ -z "${REQUESTED_VERSION}" ]]; then
102+ echo "Error: Version input is required (or use 'latest')"
103103 exit 1
104104 fi
105105
@@ -130,14 +130,15 @@ runs:
130130 REQUESTED_VERSION : ${{ inputs.Version }}
131131 run : |
132132 Write-Host "Requested version: [$REQUESTED_VERSION]"
133- # Resolve "" / null / latest → concrete latest version
133+ # Only resolve to latest version if explicitly set to ' latest' (case-insensitive)
134134 $req = $env:REQUESTED_VERSION
135- if ([string]::IsNullOrWhiteSpace($req) -or
136- $req.Trim().ToLower() -in @('latest','null','~')) {
137-
135+ if ($req -and $req.Trim().ToLower() -eq 'latest') {
138136 $latest = (Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest').tag_name.TrimStart('v')
139137 Write-Host "Latest stable PowerShell release detected: $latest"
140138 $env:REQUESTED_VERSION = $latest
139+ } elseif ([string]::IsNullOrWhiteSpace($req)) {
140+ Write-Host "Error: Version input is required (or use 'latest')"
141+ exit 1
141142 }
142143
143144 try {
0 commit comments