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 action for publishing package to WinGet #6308

Open
wants to merge 1 commit into
base: master
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/publish-winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Submit opam package to WinGet community repository

on:
workflow_dispatch:
release:
types: [published]

jobs:
publish-winget:
name: Publish to winget repository
runs-on: windows-latest
steps:
- 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: |
# WinGet PackageIdentifier
$packageId = "OCaml.opam"

# Fetching latest stable release from GitHub API
$github = Invoke-RestMethod -uri "https://api.github.com/repos/ocaml/opam/releases"
$targetRelease = $github | Where-Object {$_.prerelease -eq $false} | Select-Object -First 1
$installerUrl = $targetRelease | Select-Object -ExpandProperty assets -First 1 | Where-Object -Property name -match 'opam-.*-x86_64-windows\.exe$' | Select-Object -ExpandProperty browser_download_url
$packageVersion = $targetRelease.tag_name.Trim("v")

# Update package using wingetcreate
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update $packageId --version $packageVersion --urls "$installerUrl|x64" --submit --token "${{ secrets.WINGET_GITHUB_TOKEN }}"