|
| 1 | +name: WinGet Submission |
| 2 | + |
| 3 | +# Manually-gated submission of a published Windows release to the winget community |
| 4 | +# repository (microsoft/winget-pkgs). Run this AFTER you've eyeballed the GitHub release. |
| 5 | +# |
| 6 | +# Unlike the PowerToys "wingetcreate update" approach, this regenerates our full multi-file |
| 7 | +# manifest from source (windows/packaging/winget) so the framework Dependencies block is |
| 8 | +# always present, instead of inheriting whatever the previously published version declared. |
| 9 | +# |
| 10 | +# Requires a repository secret named WINGET_CREATE_GITHUB_TOKEN: a classic PAT from an |
| 11 | +# account that can fork microsoft/winget-pkgs, with the `public_repo` scope. wingetcreate |
| 12 | +# forks winget-pkgs under that account and opens the PR from the fork (no org SSO needed). |
| 13 | +# See https://aka.ms/winget-create-token. |
| 14 | + |
| 15 | +on: |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + tag: |
| 19 | + description: 'Windows release tag to submit (for example, v1.0.7-windows)' |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +env: |
| 27 | + PACKAGE_FAMILY_NAME: Refractored.TinyClips_vmshqmcyy894t |
| 28 | + |
| 29 | +jobs: |
| 30 | + submit: |
| 31 | + name: Submit to winget-pkgs |
| 32 | + runs-on: windows-latest |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@v6 |
| 37 | + |
| 38 | + - name: Resolve release version |
| 39 | + shell: pwsh |
| 40 | + run: | |
| 41 | + $tag = "${{ inputs.tag }}" |
| 42 | + if ($tag -notmatch '^v(?<base>\d+\.\d+\.\d+)(?:\.(?<revision>\d+))?-windows$') { |
| 43 | + throw "Windows release tags must look like v1.2.3-windows or v1.2.3.4-windows. Got '$tag'." |
| 44 | + } |
| 45 | +
|
| 46 | + $revision = if ($Matches.revision) { $Matches.revision } else { "0" } |
| 47 | + $packageVersion = "$($Matches.base).$revision" |
| 48 | + $assetVersion = if ($Matches.revision) { "$($Matches.base).$revision" } else { $Matches.base } |
| 49 | +
|
| 50 | + "RELEASE_TAG=$tag" >> $env:GITHUB_ENV |
| 51 | + "PACKAGE_VERSION=$packageVersion" >> $env:GITHUB_ENV |
| 52 | + "ASSET_VERSION=$assetVersion" >> $env:GITHUB_ENV |
| 53 | +
|
| 54 | + - name: Download release MSIX packages |
| 55 | + shell: pwsh |
| 56 | + env: |
| 57 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + run: | |
| 59 | + New-Item -ItemType Directory -Force -Path packages | Out-Null |
| 60 | + gh release download $env:RELEASE_TAG ` |
| 61 | + --repo ${{ github.repository }} ` |
| 62 | + --pattern "TinyClips-$env:ASSET_VERSION-x64.msix" ` |
| 63 | + --pattern "TinyClips-$env:ASSET_VERSION-arm64.msix" ` |
| 64 | + --dir packages |
| 65 | + Get-ChildItem packages | Format-Table Name, Length |
| 66 | +
|
| 67 | + - name: Generate winget manifest |
| 68 | + shell: pwsh |
| 69 | + run: | |
| 70 | + $manifestDir = "manifests" |
| 71 | + New-Item -ItemType Directory -Force -Path $manifestDir | Out-Null |
| 72 | + Copy-Item windows/packaging/winget/Refractored.TinyClips.yaml $manifestDir |
| 73 | + Copy-Item windows/packaging/winget/Refractored.TinyClips.locale.en-US.yaml $manifestDir |
| 74 | +
|
| 75 | + foreach ($manifest in Get-ChildItem $manifestDir/*.yaml) { |
| 76 | + $content = Get-Content $manifest.FullName -Raw |
| 77 | + $content = $content -replace 'PackageVersion: .*', "PackageVersion: $env:PACKAGE_VERSION" |
| 78 | + Set-Content -Path $manifest.FullName -Value $content -Encoding UTF8 |
| 79 | + } |
| 80 | +
|
| 81 | + $x64Package = "packages/TinyClips-$env:ASSET_VERSION-x64.msix" |
| 82 | + $arm64Package = "packages/TinyClips-$env:ASSET_VERSION-arm64.msix" |
| 83 | +
|
| 84 | + $x64InstallerHash = (winget hash $x64Package | Select-String 'InstallerSha256:' | Select-Object -Last 1).ToString().Split(':')[1].Trim() |
| 85 | + $x64SignatureHash = (winget hash --msix $x64Package | Select-String 'SignatureSha256:' | Select-Object -Last 1).ToString().Split(':')[1].Trim() |
| 86 | + $arm64InstallerHash = (winget hash $arm64Package | Select-String 'InstallerSha256:' | Select-Object -Last 1).ToString().Split(':')[1].Trim() |
| 87 | + $arm64SignatureHash = (winget hash --msix $arm64Package | Select-String 'SignatureSha256:' | Select-Object -Last 1).ToString().Split(':')[1].Trim() |
| 88 | +
|
| 89 | + @" |
| 90 | + # yaml-language-server: `$schema=https://aka.ms/winget-manifest.installer.1.12.0.schema.json |
| 91 | + # Installer manifest for the signed, framework-dependent MSIX produced by the Windows |
| 92 | + # Release workflow. The package does NOT bundle the .NET or Windows App SDK runtimes; |
| 93 | + # they are declared below as winget package dependencies so winget installs them before |
| 94 | + # the app (and the Windows App SDK runtime is also auto-acquired by the OS Store). |
| 95 | + PackageIdentifier: Refractored.TinyClips |
| 96 | + PackageVersion: $env:PACKAGE_VERSION |
| 97 | + MinimumOSVersion: 10.0.22000.0 |
| 98 | + InstallerType: msix |
| 99 | + Scope: user |
| 100 | + InstallModes: |
| 101 | + - silent |
| 102 | + - silentWithProgress |
| 103 | + PackageFamilyName: $env:PACKAGE_FAMILY_NAME |
| 104 | + Dependencies: |
| 105 | + PackageDependencies: |
| 106 | + - PackageIdentifier: Microsoft.DotNet.DesktopRuntime.10 |
| 107 | + - PackageIdentifier: Microsoft.WindowsAppRuntime.1.8 |
| 108 | + Installers: |
| 109 | + - Architecture: x64 |
| 110 | + InstallerUrl: https://github.com/${{ github.repository }}/releases/download/$env:RELEASE_TAG/TinyClips-$env:ASSET_VERSION-x64.msix |
| 111 | + InstallerSha256: $x64InstallerHash |
| 112 | + SignatureSha256: $x64SignatureHash |
| 113 | + - Architecture: arm64 |
| 114 | + InstallerUrl: https://github.com/${{ github.repository }}/releases/download/$env:RELEASE_TAG/TinyClips-$env:ASSET_VERSION-arm64.msix |
| 115 | + InstallerSha256: $arm64InstallerHash |
| 116 | + SignatureSha256: $arm64SignatureHash |
| 117 | + ManifestType: installer |
| 118 | + ManifestVersion: 1.12.0 |
| 119 | + "@ | ForEach-Object { $_ -replace '^ ', '' } | |
| 120 | + Set-Content -Path (Join-Path $manifestDir "Refractored.TinyClips.installer.yaml") -Encoding UTF8 |
| 121 | +
|
| 122 | + # winget validate leaves a non-zero exit code for non-fatal warnings (and an older |
| 123 | + # runner winget may not recognize the 1.12.0 schema header). Treat the run as a |
| 124 | + # success only when the output text confirms validation succeeded. |
| 125 | + $validateOutput = winget validate --manifest $manifestDir 2>&1 | Out-String |
| 126 | + Write-Host $validateOutput |
| 127 | + if ($validateOutput -notmatch 'Manifest validation succeeded') { |
| 128 | + throw "winget validate failed:`n$validateOutput" |
| 129 | + } |
| 130 | + $global:LASTEXITCODE = 0 |
| 131 | +
|
| 132 | + - name: Submit to winget-pkgs |
| 133 | + shell: pwsh |
| 134 | + env: |
| 135 | + WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }} |
| 136 | + run: | |
| 137 | + if ([string]::IsNullOrWhiteSpace($env:WINGET_CREATE_GITHUB_TOKEN)) { |
| 138 | + throw "The WINGET_CREATE_GITHUB_TOKEN repository secret is not set. Add a classic PAT (public_repo scope) that can fork microsoft/winget-pkgs. See https://aka.ms/winget-create-token." |
| 139 | + } |
| 140 | +
|
| 141 | + curl.exe -JLO https://aka.ms/wingetcreate/latest |
| 142 | + .\wingetcreate.exe submit --token $env:WINGET_CREATE_GITHUB_TOKEN manifests |
0 commit comments