diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml index 355903863..b065867d9 100644 --- a/.github/workflows/winget.yml +++ b/.github/workflows/winget.yml @@ -9,8 +9,10 @@ run-name: WinGet ${{ inputs.version }}${{ inputs.dry_run && ' (dry run)' || '' } # exempt. Run it by hand to retry a version. # # Needs the WINGET_TOKEN secret: a classic GitHub token with the public_repo -# scope. The pull request opens from that account's fork of winget-pkgs, which -# the first run creates. That account's first pull request there also needs +# and workflow scopes (komac brings the fork up to date with winget-pkgs, whose +# own workflow files change, and GitHub refuses that push without workflow). +# The pull request opens from that account's fork of winget-pkgs, which the +# first run creates. That account's first pull request there also needs # Microsoft's CLA, agreed to once in a comment on it. on: workflow_dispatch: @@ -38,8 +40,59 @@ env: KOMAC_SHA256: b03b020eec98acfb0b53e284a6e21815b884be33de6785b97e7a120f0e748966 jobs: + # Until a moderator approves our first ("New package") pull request, + # Threadlines isn't in winget-pkgs and every version we send is another new + # package request that waits weeks in the same queue. So while one is open, + # skip instead of piling up more; the oldest keeps our place in line. Once + # it's approved, versions go out as normal updates. Send the newest version + # by hand that day so winget doesn't sit on the approved one. + check: + name: Check whether Threadlines is listed + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + waiting: ${{ steps.listing.outputs.waiting }} + steps: + - name: Look for the package and a waiting request + id: listing + env: + GH_TOKEN: ${{ github.token }} + WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }} + run: | + set -euo pipefail + status="$(gh api --include repos/microsoft/winget-pkgs/contents/manifests/t/Threadlines/Threadlines 2> /dev/null | head -n 1 || true)" + if [[ "$status" == *" 200"* ]]; then + echo "Threadlines.Threadlines is in winget-pkgs; sending an update." + echo "waiting=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + if [[ "$status" != *" 404"* ]]; then + echo "::error::Couldn't tell whether Threadlines is in winget-pkgs (got '${status}')." + exit 1 + fi + # Only our own requests count: anyone can open a pull request with + # this title, and a stranger's must not hold back our releases. + if [[ -z "$WINGET_TOKEN" ]]; then + echo "::error::Add a WINGET_TOKEN secret (a classic GitHub token with public_repo and workflow) to send releases to winget." + exit 1 + fi + owner="$(GH_TOKEN="$WINGET_TOKEN" gh api user --jq .login)" + pending="$(gh api -X GET search/issues \ + -f q="repo:microsoft/winget-pkgs is:pr is:open author:${owner} in:title \"New package: Threadlines.Threadlines\"" \ + --jq '[.items[].html_url] | join(" ")')" + if [[ -n "$pending" ]]; then + echo "::notice::Skipped: our first winget request still waits for a moderator (${pending}). Send the newest version by hand once it's approved." + echo "waiting=true" >> "$GITHUB_OUTPUT" + else + echo "No Threadlines package and no waiting request; sending a new one." + echo "waiting=false" >> "$GITHUB_OUTPUT" + fi + submit: name: Send to winget-pkgs + needs: check + # A dry run only builds and checks the manifests, so it runs either way. + if: ${{ inputs.dry_run || needs.check.outputs.waiting != 'true' }} runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -48,7 +101,7 @@ jobs: WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }} run: | if [[ -z "$WINGET_TOKEN" ]]; then - echo "::error::Add a WINGET_TOKEN secret (a classic GitHub token with public_repo) to send releases to winget." + echo "::error::Add a WINGET_TOKEN secret (a classic GitHub token with public_repo and workflow) to send releases to winget." exit 1 fi diff --git a/docs/release.md b/docs/release.md index 084e7dce0..1d4bd1cf7 100644 --- a/docs/release.md +++ b/docs/release.md @@ -319,14 +319,25 @@ version shows up in winget once a moderator merges it. The listing text Setup, once: - Add a `WINGET_TOKEN` repository secret: a classic GitHub token with the - `public_repo` scope. Pull requests open from that account's fork of - winget-pkgs, which the first run creates. + `public_repo` and `workflow` scopes. Pull requests open from that account's + fork of winget-pkgs, which the first run creates. Without `workflow`, a run + fails with "does not have the correct permissions to execute CreateRef" + whenever winget-pkgs has changed its own workflow files since the fork's + last push. - On that account's first winget-pkgs pull request, agree to Microsoft's CLA with the comment the CLA bot asks for. To retry a version, or to check the manifests without opening a pull request, run **WinGet** by hand with that version (tick "dry run" for the check). +Until a moderator approves our first pull request, Threadlines isn't in +winget-pkgs, and every version sent is another "New package" request in a +queue that takes weeks (about eight in November 2026). So while one is open, +the workflow skips with a notice instead of opening more, and the oldest +request keeps our place in line. Updates to a listed package merge within +hours. The day the first one is approved, run **WinGet** by hand with the +newest stable version. + ## Windows Publisher Name There are two different Windows publisher surfaces: