Skip to content

Commit 6fba102

Browse files
authored
Merge pull request #722 from Trenly/WingetWorkflow
Add workflow to automatically submit to Winget
2 parents 12e8630 + d9e12af commit 6fba102

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/winget.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Submit release to the WinGet community repository
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-winget:
9+
name: Submit to WinGet repository
10+
11+
# GitHub token permissions needed for winget-create to submit a PR
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
# winget-create is only supported on Windows
17+
runs-on: windows-latest
18+
19+
# winget-create will read the following environment variable to access the GitHub token needed for submitting a PR
20+
# See https://aka.ms/winget-create-token
21+
env:
22+
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }}
23+
24+
steps:
25+
- name: Submit package using wingetcreate
26+
run: |
27+
# Set the package ID based on the release info
28+
$packageId = if (${{ !github.event.release.prerelease }}) { "GitHub.Copilot" } else { "GitHub.Copilot.Prerelease" }
29+
30+
# Get installer info from release event
31+
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
32+
$packageVersion = (${{ toJSON(github.event.release.tag_name) }})
33+
34+
# Find the download URLs for the x64 and arm64 installers separately
35+
# This allows overrides to be used so that wingetcreate does not have to guess the architecture from the filename
36+
$installerUrlx64 = $assets | Where-Object -Property name -like '*win32-x64.zip' | Select-Object -ExpandProperty browser_download_url
37+
$installerUrlarm64 = $assets | Where-Object -Property name -like '*win32-arm64.zip' | Select-Object -ExpandProperty browser_download_url
38+
39+
# Update package using wingetcreate
40+
curl.exe -JLO https://aka.ms/wingetcreate/latest
41+
.\wingetcreate.exe update $packageId `
42+
--version $packageVersion `
43+
--urls "$installerUrlx64|x64" "$installerUrlarm64|arm64" `
44+
--submit

0 commit comments

Comments
 (0)