diff --git a/.github/workflows/testAndPublish.yml b/.github/workflows/testAndPublish.yml index d1733e8738d..54f48159245 100644 --- a/.github/workflows/testAndPublish.yml +++ b/.github/workflows/testAndPublish.yml @@ -753,3 +753,39 @@ jobs: --repo ${{ github.repository }} \ --clobber \ $NVDA_EXE_NAME#Installer + + submit-winget: + name: Submit manifest to WinGet Packages Repository + needs: [release] + runs-on: windows-latest + if: startsWith(github.ref_name, 'release-') + permissions: + contents: read + steps: + - name: Submit package using wingetcreate + env: + GH_TOKEN: ${{ github.token }} + # wingetcreate will read the token from the below environment variable + # Reference: https://aka.ms/winget-create-token + WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }} + run: | + # Strip the 'release-' prefix to get the package version + $packageVersion = "${{ github.ref_name }}" -replace '^release-', '' + + # Determine the appropriate package ID based on stable, beta, or rc release + $isBeta = "${{ github.ref_name }}" -match 'beta' + $isRc = "${{ github.ref_name }}" -match 'rc' + $wingetPackageId = if ($isBeta) { "NVAccess.NVDA.Beta" } elseif ($isRc) { "NVAccess.NVDA.RC" } else { "NVAccess.NVDA" } + + # Retrieve the .exe installer URL from the published GitHub release + $releaseAssets = gh release view "${{ github.ref_name }}" ` + --repo "${{ github.repository }}" ` + --json assets | ConvertFrom-Json + $installerUrl = ($releaseAssets.assets | Where-Object { $_.name -like "*.exe" }).url + + # Download wingetcreate and open a PR against the winget-pkgs repository + curl.exe -JLO https://aka.ms/wingetcreate/latest + .\wingetcreate.exe update $wingetPackageId ` + --version $packageVersion ` + --urls $installerUrl ` + --submit diff --git a/ci/README.md b/ci/README.md index a10b3ee896a..5bcab761764 100644 --- a/ci/README.md +++ b/ci/README.md @@ -35,6 +35,7 @@ Some of these steps run concurrently. * On snapshot builds, deploy to the server. * On beta branch builds, upload translation to Crowdin. * On release builds, publish the release on GitHub and deploy to the server. + * On release builds, submit a PR for the new version to the WinGet community repository. * Clean up build cache. ### Build behaviours @@ -182,6 +183,16 @@ To ensure this step of tagged builds succeeds, set: * `VT_API_KEY` as a secret. +### WinGet manifest submission + +On release builds, a PR is automatically submitted to the [WinGet community repository](https://github.com/microsoft/winget-pkgs) with the new version's manifest. + +To ensure this step of release builds succeeds, set: + +* `WINGET_CREATE_GITHUB_TOKEN` as a secret with a GitHub personal access token that has permission to fork and open pull requests against `microsoft/winget-pkgs`. + +See [the winget-create documentation](https://aka.ms/winget-create-token) for the required token scopes. + ### GitHub Discussions category This is only used when building tagged builds.