Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Submit release to the WinGet community repository

on:
release:
types: [published]

jobs:
publish-winget:
name: Submit to WinGet repository

# GitHub token permissions needed for winget-create to submit a PR
permissions:
contents: read
pull-requests: write

# winget-create is only supported on Windows
runs-on: windows-latest

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Trailing whitespace present on this line.

Suggested change

Copilot uses AI. Check for mistakes.
# winget-create will read the following environment variable to access the GitHub token needed for submitting a PR
# See https://aka.ms/winget-create-token
env:
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }}

steps:
- name: Submit package using wingetcreate
run: |
# Set the package ID based on the release info
$packageId = if (${{ !github.event.release.prerelease }}) { "GitHub.Copilot" } else { "GitHub.Copilot.Prerelease" }
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PowerShell conditional expression is incorrect. Using ${{ !github.event.release.prerelease }} inside a PowerShell script will evaluate to a literal string "True" or "False" rather than a PowerShell boolean. This will cause the conditional to always evaluate to true (as non-empty strings are truthy).

Replace with:

$packageId = if ('${{ github.event.release.prerelease }}' -eq 'false') { "GitHub.Copilot" } else { "GitHub.Copilot.Prerelease" }
Suggested change
$packageId = if (${{ !github.event.release.prerelease }}) { "GitHub.Copilot" } else { "GitHub.Copilot.Prerelease" }
$packageId = if ('${{ github.event.release.prerelease }}' -eq 'false') { "GitHub.Copilot" } else { "GitHub.Copilot.Prerelease" }

Copilot uses AI. Check for mistakes.
# Get installer info from release event
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
$packageVersion = (${{ toJSON(github.event.release.tag_name) }})
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toJSON function is unnecessary here and will add extra quotes around the tag name. The tag_name is already a string, so wrapping it with toJSON() and then assigning it to a PowerShell variable will result in a doubly-quoted string like "v1.0.0" instead of v1.0.0.

Replace with:

$packageVersion = '${{ github.event.release.tag_name }}'
Suggested change
$packageVersion = (${{ toJSON(github.event.release.tag_name) }})
$packageVersion = '${{ github.event.release.tag_name }}'

Copilot uses AI. Check for mistakes.
# Find the download URLs for the x64 and arm64 installers separately
# This allows overrides to be used so that wingetcreate does not have to guess the architecture from the filename
$installerUrlx64 = $assets | Where-Object -Property name -like '*win32-x64.zip' | Select-Object -ExpandProperty browser_download_url
$installerUrlarm64 = $assets | Where-Object -Property name -like '*win32-arm64.zip' | Select-Object -ExpandProperty browser_download_url
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling if the installer URLs are not found. If the asset patterns don't match or the assets are missing, $installerUrlx64 or $installerUrlarm64 will be empty, causing the wingetcreate command to fail with unclear errors.

Consider adding validation:

if ([string]::IsNullOrEmpty($installerUrlx64) -or [string]::IsNullOrEmpty($installerUrlarm64)) {
  Write-Error "Failed to find required installer assets"
  exit 1
}
Suggested change
# Validate installer URLs
if ([string]::IsNullOrEmpty($installerUrlx64) -or [string]::IsNullOrEmpty($installerUrlarm64)) {
Write-Error "Failed to find required installer assets"
exit 1
}

Copilot uses AI. Check for mistakes.
# Update package using wingetcreate
curl.exe -JLO https://aka.ms/wingetcreate/latest
.\wingetcreate.exe update $packageId `
--version $packageVersion `
--urls "$installerUrlx64|x64" "$installerUrlarm64|arm64" `
--submit