@@ -52,12 +52,27 @@ jobs:
52
52
if : matrix.os == 'ubuntu-latest'
53
53
run : |
54
54
dotnet tool install --global PowerShell
55
+ - name : Find latest PowerShell version (Windows)
56
+ if : matrix.os == 'windows-latest'
57
+ shell : pwsh
58
+ run : |
59
+ $packageName = "powershell"
60
+ $outputText = dotnet tool search $packageName --take 1
61
+ $outputLine = ("" + $outputText)
62
+ $indexOfVersionLine = $outputLine.IndexOf($packageName)
63
+ $latestVersion = $outputLine.substring($indexOfVersionLine + $packageName.length).trim().split(" ")[0].trim()
64
+
65
+ Write-Output "Found PowerShell version: $latestVersion"
66
+ Write-Output "POWERSHELL_LATEST_VERSION=$latestVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
55
67
- name : Setup PowerShell (Windows)
56
68
if : matrix.os == 'windows-latest'
57
69
shell : cmd
58
70
run : |
59
- curl --location --output "%RUNNER_TEMP%\PowerShell-7.3.6-win-x64.msi" https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/PowerShell-7.3.6-win-x64.msi
60
- msiexec.exe /package "%RUNNER_TEMP%\PowerShell-7.3.6-win-x64.msi" /quiet USE_MU=1 ENABLE_MU=1 ADD_PATH=1 DISABLE_TELEMETRY=1
71
+ set DOWNLOAD_LINK=https://github.com/PowerShell/PowerShell/releases/download/v%POWERSHELL_LATEST_VERSION%/PowerShell-%POWERSHELL_LATEST_VERSION%-win-x64.msi
72
+ set OUTPUT_PATH=%RUNNER_TEMP%\PowerShell-%POWERSHELL_LATEST_VERSION%-win-x64.msi
73
+ echo Downloading from: %DOWNLOAD_LINK% to: %OUTPUT_PATH%
74
+ curl --location --output %OUTPUT_PATH% %DOWNLOAD_LINK%
75
+ msiexec.exe /package %OUTPUT_PATH% /quiet USE_MU=1 ENABLE_MU=1 ADD_PATH=1 DISABLE_TELEMETRY=1
61
76
- name : Setup PowerShell (macOS)
62
77
if : matrix.os == 'macos-latest'
63
78
run : |
@@ -160,12 +175,12 @@ jobs:
160
175
permissions :
161
176
contents : read
162
177
steps :
163
- - name : Git checkout
164
- uses : actions/checkout@v4
165
178
- name : Setup .NET
166
179
uses : actions/setup-dotnet@v3
167
180
with :
168
181
dotnet-version : 6.0.x
182
+ - name : Git checkout
183
+ uses : actions/checkout@v4
169
184
- name : Restore tools
170
185
run : |
171
186
dotnet tool restore
@@ -211,14 +226,14 @@ jobs:
211
226
permissions :
212
227
contents : read
213
228
steps :
214
- - name : Git checkout
215
- uses : actions/checkout@v4
216
- with :
217
- fetch-depth : 2
218
229
- name : Setup .NET
219
230
uses : actions/setup-dotnet@v3
220
231
with :
221
232
dotnet-version : 6.0.x
233
+ - name : Git checkout
234
+ uses : actions/checkout@v4
235
+ with :
236
+ fetch-depth : 2
222
237
- name : Restore tools
223
238
run : |
224
239
dotnet tool restore
0 commit comments