-
Notifications
You must be signed in to change notification settings - Fork 639
Add workflow to automatically submit to Winget #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
devm33
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a GitHub Actions workflow to automatically submit new releases to the WinGet community repository using the wingetcreate tool. The workflow triggers on release publication and uses a repository secret for authentication.
Key Changes:
- Adds automated WinGet package submission workflow triggered on release publication
- Implements logic to differentiate between stable and prerelease packages
- Downloads and executes wingetcreate to update package manifests with x64 and arm64 installers
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # winget-create is only supported on Windows | ||
| runs-on: windows-latest | ||
|
|
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
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.
| - 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" } |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
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" }| $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" } |
| # Get installer info from release event | ||
| $assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json | ||
| $packageVersion = (${{ toJSON(github.event.release.tag_name) }}) |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
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 }}'| $packageVersion = (${{ toJSON(github.event.release.tag_name) }}) | |
| $packageVersion = '${{ github.event.release.tag_name }}' |
| # 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 | ||
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
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
}| # Validate installer URLs | |
| if ([string]::IsNullOrEmpty($installerUrlx64) -or [string]::IsNullOrEmpty($installerUrlarm64)) { | |
| Write-Error "Failed to find required installer assets" | |
| exit 1 | |
| } | |
|
The workflow will fail until the prs in winget-pkgs are merged, which is why this was marked as draft |
Ah oops 😅 Looks like the PRs should make it in time before the next release thankfully 🤞 |
Yep! Looks like we should be good |
📖 Description
PR adds a GitHub action workflow for submitting the release to winget-pkgs repository.
GitHub Repository Secret
To add a personal access token (PAT), one can follow the steps listed in https://github.com/microsoft/winget-create?tab=readme-ov-file#github-personal-access-token-classic-permissions. Before this PR is merged, maintainers will need to create a repository secret with the name
WINGET_CREATE_GITHUB_TOKEN.🔗 References and Related Issues
See similar actions in the following repositories
🔍 How to Test
Action is tricky to test without a fork, but I've tested similar actions in private forks previously. One can test the wingetcreate command by omitting the --submit flag to see if the command will succeed
As a side note - if the workflow starts randomly failing, it is likely that whichever fork of winget-pkgs the repository secret is giving access to is outdated and needs to be synced with the upstream due to a bug in Octokit
✅ Checklist