Skip to content

Winget manifest uploader #620

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
27 changes: 27 additions & 0 deletions .github/workflows/winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish to Winget

on:
release:
types: [published]
Comment on lines +3 to +5

Choose a reason for hiding this comment

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

Suggested change
on:
release:
types: [published]
on:
workflow_dispatch:
release:
types: [published]

Let's add workflow_dispatch so that the job can be re-run manually from the Actions tab



env:
REGEX: 'DSC-(\d+\.\d+\.\d+(?:-preview\.\d+)?)-(?:x86_64|aarch64)-pc-windows-msvc\.zip'
Comment on lines +8 to +9

Choose a reason for hiding this comment

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

Suggested change
env:
REGEX: 'DSC-(\d+\.\d+\.\d+(?:-preview\.\d+)?)-(?:x86_64|aarch64)-pc-windows-msvc\.zip'
env:
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }}

removing REGEX env variable as not needed (assuming you agree with my suggestions above). Adding the WINGET_CREATE_GITHUB_TOKEN environment variable to be used for submission


jobs:
publish:
runs-on: windows-latest # Action can only run on Windows
steps:
- name: Publish Microsoft.DSC ${{ github.event.release.prerelease && 'Preview' || 'Stable' }}
run: |
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
$wingetRelevantAsset = $assets | Where-Object { $_.name -like '*.zip' -and $_.name -like '*.msixbundle' } | Select-Object -First 1

Choose a reason for hiding this comment

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

This code looks like it's either only gonna get the zip URL OR the MSIX URL, and we don't know which will it be?

Choose a reason for hiding this comment

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

Suggested change
$wingetRelevantAsset = $assets | Where-Object { $_.name -like '*.zip' -and $_.name -like '*.msixbundle' } | Select-Object -First 1
$x64ZIPInstallerUrl = $assets | Where-Object -Property name -like '*x86_64-pc-windows-msvc.zip' | Select-Object -ExpandProperty browser_download_url
$arm64InstallerUrl = $assets | Where-Object -Property name -like '*aarch64-pc-windows-msvc.zip' | Select-Object -ExpandProperty browser_download_url
$msixInstallerURL = $assets | Where-Object -Property name -like '*Win.msixbundle' | Select-Object -ExpandProperty browser_download_url

As I mentioned in a comment previously, the current code looks like it's either only gonna get the zip URL OR the MSIX URL, and we don't know which will it be. We should get URLs something like this instead

$regex = [Regex]::New($env:REGEX)
$version = $regex.Match($wingetRelevantAsset.name).Groups[1].Value
Comment on lines +19 to +20

Choose a reason for hiding this comment

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

Suggested change
$regex = [Regex]::New($env:REGEX)
$version = $regex.Match($wingetRelevantAsset.name).Groups[1].Value
$version = (${{ toJSON(github.event.release.tag_name) }}).Trim('v')

We don't need to perform regex matching. The version info is already available in the GitHub release event


$wingetPackage = "Microsoft.DSC${{ github.event.release.prerelease && '.Preview' || '' }}"

Choose a reason for hiding this comment

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

Suggested change
$wingetPackage = "Microsoft.DSC${{ github.event.release.prerelease && '.Preview' || '' }}"
$wingetPackage = "Microsoft.DSC"

Personally I would suggest not handling Preview releases for now to get this merged & handle preview in a future PR. The issue is that WinGet pipelines enforce that the PackageVersion should exactly match the MSIX version. For reference, the GitHub version for the latest preview is 3.2.0-preview.2, but the MSIX version is actually 3.2.2. Would need to add some logic to modify the version only for preview to get the MSIX version. You may do it here if you want, but I would suggest a separate PR since there are enough comments in this one already :D


& curl.exe -JLO https://aka.ms/wingetcreate/latest
& .\wingetcreate.exe update $wingetPackage -s -v $version -u $wingetRelevantAsset.browser_download_url -t "${{ secrets.WINGET_TOKEN }}"

Comment on lines +25 to +26

Choose a reason for hiding this comment

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

Suggested change
& .\wingetcreate.exe update $wingetPackage -s -v $version -u $wingetRelevantAsset.browser_download_url -t "${{ secrets.WINGET_TOKEN }}"
& .\wingetcreate.exe update $wingetPackage --version $version --urls $x64ZIPInstallerUrl $arm64InstallerUrl $msixInstallerURL --submit

Suggested changes to the command based on feedback above. Use of --token param is deprecated in winget-create. We should be using the WINGET_CREATE_GITHUB_TOKEN environment variable instead.


Empty file modified build.ps1
100755 → 100644
Empty file.
Loading