Skip to content

Commit 1dd30bb

Browse files
claudeben-edna
authored andcommitted
fix: resolve WinGet fork-user from token owner; add workflow_dispatch
The WinGet publish workflow was failing with: Could not resolve to a Repository with the name 'dfetch-org/winget-pkgs' Root cause: winget-releaser defaulted fork-user to the repository owner (dfetch-org), but a fine-grained PAT scoped to an organisation cannot create org-level forks — the fork of microsoft/winget-pkgs therefore never existed in dfetch-org. Fix: add a step that calls GET /user with the WINGET_TOKEN to discover the personal GitHub account that owns the token, then pass that account as fork-user to winget-releaser. komac will fork winget-pkgs into the personal account (where the token has full rights) and open the PR from there — the standard WinGet community pattern. Also add workflow_dispatch so maintainers can manually re-trigger the publish for an already-released tag (e.g. to retry 0.14.2 after updating the token). Update the token-setup comment: the PAT must be created with the user's personal account as resource owner, not the DFetch-org organisation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012NwjWMaDcFgUU1UNpQFfY4
1 parent 8e4a5e3 commit 1dd30bb

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/winget-publish.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@ name: Publish to WinGet
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
release-tag:
9+
description: 'Release tag to publish (e.g. 0.14.2)'
10+
required: true
11+
type: string
612

713
permissions:
814
contents: read
915

1016
jobs:
1117
publish:
1218
name: Publish to WinGet
13-
# Only publish versioned releases — skip the rolling 'latest' tag on main
14-
if: github.event.release.tag_name != 'latest'
19+
# For releases: skip the rolling 'latest' tag on main.
20+
# For manual dispatch: always run (the operator knows what they're doing).
21+
if: >-
22+
github.event_name != 'release' ||
23+
github.event.release.tag_name != 'latest'
1524
runs-on: ubuntu-latest
1625
concurrency:
17-
group: winget-publish-${{ github.event.release.tag_name }}
26+
group: winget-publish-${{ github.event.release.tag_name || inputs.release-tag }}
1827
cancel-in-progress: true
1928

2029
environment:
@@ -35,13 +44,27 @@ jobs:
3544
index.crates.io:443
3645
static.crates.io:443
3746
47+
- name: Resolve WinGet fork owner from token
48+
# komac forks microsoft/winget-pkgs into the fork-owner's account and
49+
# opens a PR from there. Fine-grained PATs scoped to an *organisation*
50+
# cannot create org-level forks, so we always fork into the *personal*
51+
# account that owns the token (typically the maintainer's account).
52+
id: winget-fork-owner
53+
run: |
54+
OWNER=$(curl -sf \
55+
-H "Authorization: Bearer ${{ secrets.WINGET_TOKEN }}" \
56+
https://api.github.com/user \
57+
| python3 -c "import sys, json; print(json.load(sys.stdin)['login'])")
58+
echo "fork-user=${OWNER}" >> "$GITHUB_OUTPUT"
59+
3860
- name: Publish to WinGet
3961
# Requires WINGET_TOKEN secret in the 'winget' environment.
4062
#
4163
# Setup — create a fine-grained PAT:
4264
# 1. GitHub → Settings → Developer settings → Personal access tokens
4365
# → Fine-grained tokens → Generate new token
44-
# 2. Resource owner: DFetch-org (or your user)
66+
# 2. Resource owner: YOUR PERSONAL GitHub account (not the org —
67+
# org-scoped tokens cannot create the required winget-pkgs fork)
4568
# 3. Repository access: All repositories
4669
# (needed to fork microsoft/winget-pkgs and push the manifest branch)
4770
# 4. Permissions:
@@ -52,5 +75,6 @@ jobs:
5275
uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
5376
with:
5477
identifier: DFetch-org.DFetch
55-
release-tag: ${{ github.event.release.tag_name }}
78+
release-tag: ${{ github.event.release.tag_name || inputs.release-tag }}
5679
token: ${{ secrets.WINGET_TOKEN }}
80+
fork-user: ${{ steps.winget-fork-owner.outputs.fork-user }}

0 commit comments

Comments
 (0)