Skip to content
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

Add CI action for publishing package to WinGet #564

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions .github/workflows/submit-winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Submit published release to WinGet community repository

on:
release:
types: [published]

jobs:
publish-winget:
name: Submit to WinGet repository
runs-on: windows-latest
if: ${{ !github.event.release.prerelease }}
steps:
# Sometimes wingetcreate may fail to sync fork automatically, so we do it manually here.
# Ref: https://github.com/microsoft/winget-create/issues/502
- name: Sync winget-pkgs fork
# TODO: Replace <repo-owner> with the owner of the fork
run: gh repo sync <repo-owner>/winget-pkgs -b master
env:
GH_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
- name: Submit package using wingetcreate
run: |
# Get installer info from release event
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
$x64InstallerUrl = $assets | Where-Object -Property name -eq 'sqlcmd-amd64.msi' | Select-Object -ExpandProperty browser_download_url
$armInstallerUrl = $assets | Where-Object -Property name -eq 'sqlcmd-arm.msi' | Select-Object -ExpandProperty browser_download_url
$arm64InstallerUrl = $assets | Where-Object -Property name -eq 'sqlcmd-arm64.msi' | Select-Object -ExpandProperty browser_download_url
$packageVersion = (${{ toJSON(github.event.release.tag_name) }}).Trim('v')

# Update package using wingetcreate
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update Microsoft.Sqlcmd --version $packageVersion --urls "$x64InstallerUrl|x64" "$armInstallerUrl|arm" "$arm64InstallerUrl|arm64" --submit --token "${{ secrets.WINGET_GITHUB_TOKEN }}"