Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 160fcef

Browse files
committed
Saner OS check
1 parent d4c4f2f commit 160fcef

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

action.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,47 @@ runs:
2323
# https://github.com/microsoft/winget-cli/issues/700#issuecomment-874084714
2424
using: composite
2525
steps:
26-
- name: Check runner OS
26+
- name: Check runner OS is Windows
2727
if: runner.os != 'Windows'
2828
shell: bash
2929
run: |
3030
echo "[ERROR] This action only runs on Windows runner, Current runner: ${{ runner.os }}"
3131
exit 1
3232
33+
- name: Check OS Version
34+
shell: powershell
35+
id: os_check
36+
run: |
37+
$version = (Get-WmiObject Win32_OperatingSystem).Caption
38+
echo "version=$version" >> $GITHUB_OUTPUT
39+
3340
- name: Windows Server 2025 Simple Setup
34-
if: runner.name == 'windows-2025'
41+
if: steps.os_check.outputs.version != 'Microsoft Windows Server 2022 Datacenter'
3542
shell: powershell
3643
run: winget upgrade winget --accept-package-agreements --accept-source-agreements --disable-interactivity
3744

3845
- name: Download Microsoft.UI.Xaml v2.8.6
39-
if: runner.name != 'windows-2025'
46+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
4047
shell: powershell
4148
run: |
4249
$ProgressPreference = 'SilentlyContinue'
4350
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6 -OutFile .\microsoft.ui.xaml.2.8.6.zip
4451
4552
- name: Unzip Microsoft.UI.Xaml v2.8.6
46-
if: runner.name != 'windows-2025'
53+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
4754
shell: powershell
4855
run: |
4956
Expand-Archive .\microsoft.ui.xaml.2.8.6.zip
5057
5158
- name: Download Microsoft.VCLibs.x64.14.00.Desktop
52-
if: runner.name != 'windows-2025'
59+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
5360
shell: powershell
5461
run: |
5562
$ProgressPreference = 'SilentlyContinue'
5663
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
5764
5865
- name: Determine Latest winget release via GitHub API
59-
if: runner.name != 'windows-2025'
66+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
6067
id: github_api
6168
shell: powershell
6269
run: |
@@ -80,48 +87,48 @@ runs:
8087
Write-Output "latest_winget_license_xml_uri=$latestWingetLicenseXmlUri" >> $Env:GITHUB_OUTPUT
8188
8289
- name: Download winget
83-
if: runner.name != 'windows-2025'
90+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
8491
shell: powershell
8592
run: |
8693
$ProgressPreference = 'SilentlyContinue'
8794
Invoke-WebRequest -Headers $headers -Uri "${{ steps.github_api.outputs.latest_winget_msix_bundle_uri }}" -OutFile "./winget.msixbundle"
8895
8996
- name: Download License
90-
if: runner.name != 'windows-2025'
97+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
9198
shell: powershell
9299
run: |
93100
$ProgressPreference = 'SilentlyContinue'
94101
Invoke-WebRequest -Headers $headers -Uri "${{ steps.github_api.outputs.latest_winget_license_xml_uri }}" -OutFile "./winget_License1.xml"
95102
96103
- name: Install Microsoft.UI.Xaml v2.8.6
97-
if: runner.name != 'windows-2025'
104+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
98105
shell: powershell
99106
run: |
100107
Add-AppxPackage .\microsoft.ui.xaml.2.8.6\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.8.appx
101108
102109
- name: Install Microsoft.VCLibs.x64.14.00.Desktop
103-
if: runner.name != 'windows-2025'
110+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
104111
shell: powershell
105112
run: |
106113
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
107114
108115
- name: Install winget
109-
if: runner.name != 'windows-2025'
116+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
110117
shell: powershell
111118
run: |
112119
echo "PROVISIONING WINGET"
113120
Add-AppxProvisionedPackage -Online -PackagePath ./winget.msixbundle -LicensePath ./winget_License1.xml
114121
115122
- name: Installing Winget
116-
if: runner.name != 'windows-2025'
123+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
117124
shell: powershell
118125
run: |
119126
echo "INSTALLING WINGET"
120127
$ProgressPreference = 'SilentlyContinue'
121128
Add-AppxPackage .\winget.msixbundle
122129
123130
- name: Cleanup Downloads
124-
if: runner.name != 'windows-2025'
131+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
125132
shell: powershell
126133
run: |
127134
rm Microsoft.VCLibs.x64.14.00.Desktop.appx
@@ -130,7 +137,7 @@ runs:
130137
Remove-Item -Recurse -Force .\microsoft.ui.xaml.2.8.6
131138
132139
- name: Wait to allow Installation to Finalize
133-
if: runner.name != 'windows-2025'
140+
if: steps.os_check.outputs.version == 'Microsoft Windows Server 2022 Datacenter'
134141
shell: powershell
135142
run: |
136143
foreach ($i in 1..60) {

0 commit comments

Comments
 (0)