Skip to content

packaging: template winget manifests and add release publishing - #500

Open
inqrphl wants to merge 16 commits into
mainfrom
winget-templates
Open

inqrphl wants to merge 16 commits into
mainfrom
winget-templates

Conversation

@inqrphl

@inqrphl inqrphl commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI GENERATED

Summary

This PR turns the WinGet manifests into templates.
It generates the manifests during the release workflow.
It validates the generated manifests with winget validate.
It attaches the manifests to the draft release.
It publishes the manifests through the GitHub API without cloning winget-pkgs.
It supersedes #496.

Package identifier

The package identifier stays ConSol.SNClient.

Two versions

TAG_VERSION is the release tag without the leading v.
PACKAGE_VERSION is the MSI ProductVersion and the ARP DisplayVersion.
WinGet PackageVersion must match the installed MSI.
Installer URLs use TAG_VERSION.
The generated manifests are in packaging/winget/<package-version>/.

What changed

  • Add packaging/winget/templates/*.yaml.in.
  • Add buildtools/winget_manifests.ps1.
  • Add packaging/winget/.gitignore for generated version directories.
  • Remove the static 1.01.0 manifests.
  • Add pkg-winget to the release workflow.
  • Add upload-winget-manifests to attach the zip to the draft release.
  • Add .github/workflows/winget.yml for API publishing.
  • Split the publish token into WINGET_FORK_TOKEN and WINGET_PR_TOKEN.
  • Update packaging/RELEASE.md.

build_msi.ps1 is unchanged.
The PowerShell generator reads ProductCode, ProductVersion and SHA256 from the MSIs.

Release and publish flow

  1. The tag build creates the three MSIs.
  2. pkg-winget reads the MSIs and generates the manifests.
  3. pkg-winget runs winget validate.
  4. pkg-winget creates snclient-<tag>-winget-manifests.zip.
  5. upload-winget-manifests attaches the zip to the draft release.
  6. The release is published.
  7. The fine-grained WINGET_FORK_TOKEN creates the branch and commit in the fork.
  8. The classic WINGET_PR_TOKEN opens the PR in microsoft/winget-pkgs.

The publish workflow uses the GitHub API to create blobs, a tree, a commit and a branch in the fork.
The classic token opens the PR in microsoft/winget-pkgs.
It does not clone the 500k-commit winget-pkgs repository.
A fork is still required for the PR head branch.
The fork does not need to be current.
The commit is based on the fork master.
The PR adds only the new version directory.
The PR can show an out-of-date branch.
That is expected.

Automation switch

WINGET_AUTOPUBLISH is set to false in the repository.
The release job is skipped while it is false.
Set it to true after the first package is merged.
Manual workflow_dispatch runs with dry_run=true by default.
Set dry_run=false to publish manually.

Setup:

  • Create a fork of microsoft/winget-pkgs.
  • Set WINGET_FORK_OWNER to inqrphl.
  • Add a fine-grained PAT as WINGET_FORK_TOKEN.
  • The fine-grained token needs Contents: Read and write on inqrphl/winget-pkgs.
  • Add a classic PAT with public_repo as WINGET_PR_TOKEN.
  • The classic token opens the PR in microsoft/winget-pkgs.
  • The fine-grained token owner must have write access to the fork.
  • The classic token owner must own the fork.

Supersedes #496

#496 used vedantmgoyal9/winget-releaser and the identifier ConSolMonitoring.SNClient.
It also used the release tag as the package version, which would be 1.02 instead of 1.02.0.
This PR keeps the release trigger and the fork setup.
It replaces the action with the generated manifests and the API publisher.
It uses ConSol.SNClient and the MSI version.

Validation

  • The PowerShell generator was run with the three v1.01.0 release MSIs.
  • Its output matches the previously validated v1.01.0 manifests exactly.
  • The templates and workflows parse as YAML.
  • The PowerShell generator validates the full 8-4-4-4-12 ProductCode GUID.
  • The generator resolves the output directory to an absolute path before writing.
  • winget validate succeeded on the generated 1.01.0 manifests.
  • The CI job runs winget validate on every release.

Reviewer test on Windows:

.\buildtools\winget_manifests.ps1 `
  -TagVersion 1.01 `
  -ReleaseDate 2026-10-29 `
  -MsiX64 <x64.msi> `
  -MsiX86 <x86.msi> `
  -MsiArm64 <arm64.msi>
winget validate --manifest packaging\winget\1.01.0

First submission

The first v1.01.0 submission is manual.
Generate the 1.01.0 manifests from the three release MSIs.
Copy them to manifests/c/ConSol/SNClient/1.01.0/.
WINGET_AUTOPUBLISH stays false until that PR is merged.

Checklist

  • PowerShell generator matches the validated 1.01.0 manifests.
  • Templates and workflows parse.
  • PowerShell ProductCode and output path checks.
  • Local winget validate of the generated 1.01.0 manifests.
  • pkg-winget job runs on the next tag.
  • First winget-pkgs submission.

inqrphl and others added 8 commits November 13, 2026 18:31
Add shell and PowerShell manifest generators.
Generate and validate manifests in the release workflow.
Publish through the GitHub API without cloning winget-pkgs.
Supersede the winget-releaser workflow from #496.
Run the version helper from the repository root.
Avoid GNU dirname and cd options.
Use an explicit empty CDPATH for the script directory lookup.
Create the new version commit on the fork master.
The PR adds only the new version directory.
Use a fine-grained token for fork branch and commit writes.
Use a classic public_repo token for the upstream pull request.
Match the token name to the WINGET_FORK_OWNER variable.
The PR token stays WINGET_PR_TOKEN.
$message = if ($isNewPackage) { "New package: $packageIdentifier $packageVersion" } else { "Update $packageIdentifier to $packageVersion" }

# The fork master can be behind upstream.
# The PR adds only the new version directory, so the fork does not need to be current.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the most complicated part of the PR, and the hardest script section starts here.

uses the github HTTP API to create a new branch, upload files as blobs? , generates a commit JSON, uploads it etc.

Did not look into the references for every API call here.

@inqrphl
inqrphl marked this pull request as ready for review November 23, 2026 10:45
@inqrphl
inqrphl requested a review from sni November 23, 2026 10:45
@inqrphl

inqrphl commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

The repository variables/secrets WINGET_FORK_OWNER , WINGET_FORK_TOKEN , WINGET_PR_TOKEN have been set.

WINGET_AUTOPUBLISH is still false.

Comment thread buildtools/winget_manifests.ps1 Resolved
@sni

sni commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

AI did find some more things to check:

Must fix before merge

  1. The upload and download jobs disagree on the artifact name. In builds.yml:499–504, archive: false makes upload-artifact ignore name: and use the filename, snclient-<version>-winget-manifests.zip. The download step asks for winget-manifests, so it cannot find the artifact. Smallest fix: remove archive: false from this upload. The action will create a named artifact containing the ZIP, and the existing download step will restore the ZIP as a file.
  2. gh release upload has no repository context. The new upload job neither checks out the repository nor supplies --repo. GITHUB_TOKEN authenticates gh; it does not select the repository. Once finding 1 is fixed, this is the next failure. Set GH_REPO: ${{ github.repository }} in the job environment, as the publisher already does.

Other mistakes worth fixing

  1. Retries are not safe. The branch name uses GITHUB_RUN_ID, which stays the same on a rerun. If branch creation succeeds but opening the PR fails, rerunning the job fails because the branch already exists. A fresh dispatch has the opposite problem: it can open a duplicate while the first PR awaits merge. Use one branch per package version, reuse it on retry, and check for an existing open PR.
  2. Every API error means “not found.” The existence checks treat a rate limit, permission error, or GitHub outage like a missing package. Only continue on HTTP 404; stop on other failures.
  3. The Linux generator accepts malformed input. In winget_manifests.sh:70–107, shell * means “any characters,” not “more digits.” A version such as 1.2.3oops passes, as does {oops} for a ProductCode. Require numeric version components and a full GUID before writing the files.

Fix the manifest artifact name and release upload repository.
Reuse one branch per package version and an open PR.
Only treat HTTP 404 as a missing resource.
Validate version components and ProductCodes in the shell generator.
@inqrphl

inqrphl commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

I let my AI handle the concerns, here is its output

======================

Fixed in cceaeaf.

  1. Removed archive: false; the artifact is now named winget-manifests and contains the ZIP.
  2. Added GH_REPO to upload-winget-manifests.
  3. The branch is consol-snclient-<package-version>.
    Retries reuse and update it.
    The PR step reuses an existing open PR.
  4. Existence checks use the HTTP status.
    Only 404 means missing.
    Other statuses fail.
  5. The shell generator validates numeric version components and full braced GUIDs.

The workflows parse as YAML and the publisher PowerShell blocks parse.
The release-only jobs were not run.

@sni
sni requested a balanced review from Copilot November 24, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Relative output paths can cause generation failures or misplaced manifests after Set-Location, and incomplete ProductCode validation allows malformed GUIDs into generated manifests.

2 open issues
What changed in this PR

This PR adds WinGet manifest generation and publishing to SNClient’s release process. It keeps ConSol.SNClient and separates MSI package versions from release-tag versions.

Changes:

  • Replace static manifests with templates and add shell and PowerShell generators.
  • Generate, validate, and attach manifest archives during tagged builds.
  • Add API-based publishing to microsoft/winget-pkgs, with separate tokens, an automation switch, and manual dry runs.
File Description
packaging/​winget/​templates/​ConSol.SNClient.yaml.in Template the package version.
packaging/​winget/​templates/​ConSol.SNClient.locale.en-US.yaml.in Template the package version and release-notes URL.
packaging/​winget/​templates/​ConSol.SNClient.installer.yaml.in Template installer URLs, hashes, ProductCodes, and release metadata.
packaging/​winget/​.gitignore Ignore generated version directories.
packaging/​RELEASE.md Document manual generation and automated publishing setup.
Makefile Add manifest generation variables, target, and cleanup.
buildtools/​winget_manifests.sh Generate manifests from supplied installer metadata.
buildtools/​winget_manifests.ps1 Read MSI metadata and generate manifests on Windows.
buildtools/​get_winget_version Derive a three-part package version from the project version.
.github/​workflows/​winget.yml Create fork branches and upstream pull requests through the GitHub API.
.github/​workflows/​builds.yml Generate, validate, archive, and upload release manifests.

Review effort: Balanced

Comment thread buildtools/winget_manifests.ps1 Resolved
Comment thread buildtools/winget_manifests.ps1 Resolved
inqrphl and others added 6 commits November 24, 2026 14:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Only the winget_manifests.ps1 script remains, which is used in the CI.
Remove the unused get_winget_version helper.
Document the PowerShell-only manual release flow.
@inqrphl
inqrphl marked this pull request as draft November 24, 2026 13:21
@inqrphl

inqrphl commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Removed the shell generator and the unused get_winget_version helper.
PowerShell is now the only manifest generator.
The current PowerShell output still matches the v1.01.0 manifests.

Copilot's ProductCode and OutDir comments are fixed:

  • 1fa6f7a8 validates the full 8-4-4-4-12 GUID.
  • 9a36e44b resolves the output directory to an absolute path.
    Both threads are resolved.

The PR body and packaging/RELEASE.md now describe the PowerShell-only flow.

@inqrphl
inqrphl marked this pull request as ready for review November 24, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants