-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
127 lines (112 loc) · 4.92 KB
/
action.yml
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
name: Install winget
description: Installs a version of winget
author: Dominion/Cyberboss
branding:
icon: arrow-down-circle
color: blue
inputs:
GITHUB_TOKEN:
description: 'No scopes GitHub token for querying the API and downloading from winget-cli releases'
required: false
default: 'NONE'
wget_release_id:
description: 'Specify desired release-id of winget can be specified here. By default, a recent stable release will be selected by the action author. To see what versions are available, look into https://api.github.com/repos/microsoft/winget-cli/releases'
required: false
default: '164835566' # latest can be used here
outputs:
winget-version:
description: "The version of winget installed"
value: ${{ steps.winget-version.outputs.winget-version }}
runs:
# Hacked together https://github.com/microsoft/winget-cli/issues/1861#issuecomment-1352784247
# https://github.com/microsoft/winget-cli/issues/700#issuecomment-874084714
using: composite
steps:
- name: Download Microsoft.UI.Xaml v2.8.6
shell: powershell
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6 -OutFile .\microsoft.ui.xaml.2.8.6.zip
- name: Unzip Microsoft.UI.Xaml v2.8.6
shell: powershell
run: |
Expand-Archive .\microsoft.ui.xaml.2.8.6.zip
- name: Download Microsoft.VCLibs.x64.14.00.Desktop
shell: powershell
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
- name: Determine Latest winget release via GitHub API
id: github_api
shell: powershell
run: |
$ProgressPreference = 'SilentlyContinue'
if ("${{ inputs.GITHUB_TOKEN }}" -ne "NONE") {
$headers = @{ "Authorization" = "Bearer ${{ inputs.GITHUB_TOKEN }}" }
Write-Host "Token present"
} else {
$headers = @{}
Write-Host "No token present"
}
$releaseURL = "https://api.github.com/repos/microsoft/winget-cli/releases/${{ inputs.wget_release_id }}"
$gitHubReleasesResponse = Invoke-RestMethod $releaseURL -Headers $headers
$wingetReleaseAssets = $gitHubReleasesResponse.assets
$latestWingetMsixBundleUri = $wingetReleaseAssets.browser_download_url | Where-Object {$_.EndsWith(".msixbundle")}
$latestWingetLicenseXmlUri = $wingetReleaseAssets.browser_download_url | Where-Object {$_.EndsWith("License1.xml")}
Write-Host "latest_winget_msix_bundle_uri=$latestWingetMsixBundleUri"
Write-Host "latest_winget_license_xml_uri=$latestWingetLicenseXmlUri"
Write-Output "latest_winget_msix_bundle_uri=$latestWingetMsixBundleUri" >> $Env:GITHUB_OUTPUT
Write-Output "latest_winget_license_xml_uri=$latestWingetLicenseXmlUri" >> $Env:GITHUB_OUTPUT
- name: Download winget
shell: powershell
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Headers $headers -Uri "${{ steps.github_api.outputs.latest_winget_msix_bundle_uri }}" -OutFile "./winget.msixbundle"
- name: Download License
shell: powershell
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Headers $headers -Uri "${{ steps.github_api.outputs.latest_winget_license_xml_uri }}" -OutFile "./winget_License1.xml"
- name: Install Microsoft.UI.Xaml v2.8.6
shell: powershell
run: |
Add-AppxPackage .\microsoft.ui.xaml.2.8.6\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.8.appx
- name: Install Microsoft.VCLibs.x64.14.00.Desktop
shell: powershell
run: |
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
- name: Install winget
shell: powershell
run: |
echo "PROVISIONING WINGET"
Add-AppxProvisionedPackage -Online -PackagePath ./winget.msixbundle -LicensePath ./winget_License1.xml
- name: Installing Winget
shell: powershell
run: |
echo "INSTALLING WINGET"
$ProgressPreference = 'SilentlyContinue'
Add-AppxPackage .\winget.msixbundle
- name: Cleanup Downloads
shell: powershell
run: |
rm Microsoft.VCLibs.x64.14.00.Desktop.appx
rm ./winget_License1.xml
rm ./winget.msixbundle
Remove-Item -Recurse -Force .\microsoft.ui.xaml.2.8.6
- name: Wait to allow Installation to Finalize
shell: powershell
run: |
foreach ($i in 1..60) {
Start-Sleep -Seconds 1
Write-Host "Waiting for winget to install... ${i}"
if (Get-Command winget -ErrorAction SilentlyContinue) {
break
}
}
- name: Output winget Version
id: winget-version
shell: powershell
run: |
$version=winget --version
Write-Host "$version"
Write-Output "winget-version=$version" >> $Env:GITHUB_OUTPUT