@@ -22,23 +22,42 @@ jobs:
2222 fail-fast : false
2323 matrix :
2424 os : [ubuntu-latest, windows-latest, macOS-latest]
25- version : ['', ' 7.4.7', '7.5.0']
25+ version : ['', null, 'latest', ' 7.4.7', '7.5.0'] # '' → should resolve to latest
2626 runs-on : ${{ matrix.os }}
27- name : ${{ matrix.os }} - ${{ matrix.version }}
27+ name : ${{ matrix.os }} - ${{ matrix.version == '' && 'latest' || matrix.version }}
2828 steps :
29- # Need to check out as part of the test, as its a local action
29+ # 1. Checkout the repo so the local action is available
3030 - name : Checkout repo
3131 uses : actions/checkout@v4
3232
33+ # 2. Run the action under test
3334 - name : Action-Test
3435 uses : ./
3536 with :
3637 Version : ${{ matrix.version }}
3738
38- - name : Test version
39+ # 3. Verify the installed PowerShell version
40+ - name : Verify installed version
3941 shell : pwsh
4042 run : |
41- $PSVersionTable | Format-Table -AutoSize
42- if ($PSVersionTable.PSVersion -ne '${{ matrix.version }}') {
43- throw "Failed to install the expected version"
43+ # Requested version that came from the matrix
44+ $requested = '${{ matrix.version }}'
45+
46+ # When empty / 'null' / 'latest' → resolve to latest stable release
47+ if ([string]::IsNullOrWhiteSpace($requested) -or
48+ $requested.Trim().ToLower() -in @('latest','null')) {
49+
50+ $requested = (Invoke-RestMethod `
51+ -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest'
52+ ).tag_name.TrimStart('v')
53+ Write-Host "Resolved 'latest' → $requested"
54+ }
55+
56+ # Actual version installed by the action
57+ $installed = ($PSVersionTable.PSVersion).ToString()
58+ Write-Host "Installed PowerShell version: $installed"
59+ Write-Host "Expected PowerShell version: $requested"
60+
61+ if ($installed -ne $requested) {
62+ throw "Failed: expected $requested but got $installed"
4463 }
0 commit comments