Skip to content

Commit 46fbb3e

Browse files
committed
docs: add post submit winget pkg
1 parent 89ffa57 commit 46fbb3e

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-0
lines changed
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
---
2+
title: How to submit a winget package to the package repository
3+
layout: post
4+
categories: contributing, applicationmanagement
5+
---
6+
7+
## Index
8+
9+
- [Index](#index)
10+
- [Introduction](#introduction)
11+
- [Background: The winget package repository](#background-the-winget-package-repository)
12+
- [Prerequisites](#prerequisites)
13+
- [Steps](#steps)
14+
- [Preparation and validation](#preparation-and-validation)
15+
- [Create the winget manifest files for the installer package](#create-the-winget-manifest-files-for-the-installer-package)
16+
- [Modify the manifest files and store them in a new branch of your forked repository](#modify-the-manifest-files-and-store-them-in-a-new-branch-of-your-forked-repository)
17+
- [Validate the manifest files](#validate-the-manifest-files)
18+
- [Test the manifest with Windows Sandbox](#test-the-manifest-with-windows-sandbox)
19+
- [Commit an push your changes](#commit-an-push-your-changes)
20+
- [Create a pull request to the microsoft/winget-pkgs repository](#create-a-pull-request-to-the-microsoftwinget-pkgs-repository)
21+
- [After successful merging of your pull request](#after-successful-merging-of-your-pull-request)
22+
- [Closing notes](#closing-notes)
23+
- [References](#references)
24+
25+
## Introduction
26+
27+
When using Windows client systems, installing applications and keeping them up-to-date used to be quite a hassle in the old days. In the past, I used to rely on [Chocolatey](https://chocolatey.org/) to keep all my applications up-to-date. Nowadays, I prefer to use the built-in [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) tool to install and update packages on Windows client devices.
28+
29+
However, sometimes you can run into one of these scenarios:
30+
31+
- The application you want to install is not available for installation using winget.
32+
- The latest version of the application is not yet available for updating using winget.
33+
34+
Not all application publishers, including Microsoft, update the Winget package when a new version of their application is released. A lot of winget packages are being submitted by the community.
35+
Other times, it just takes quite a while for a package to get updated, and personally I don't like waiting.
36+
Thankfully, everybody can submit a winget package.
37+
38+
Apart from doing yourself a favour, you will actively contributing to the community, helping other users of the application that use winget for package management. And it's a great learning experience, covering loads of different technology and tooling.
39+
40+
This article will show you how to update an existing winget package. In this example, I have used the Bicep cli as an example, as this is a package I frequently submit.
41+
42+
### Background: The winget package repository
43+
44+
The winget package repository is stored on Github and can be found here: [winget-pkgs](https://github.com/microsoft/winget-pkgs)
45+
The actual software is not stored in this repository, but only manifest files that point to the actual installation package on a different location. This can be another GitHub repository, or the publisher's website for example.
46+
47+
All winget packages are stored in the [manifests](https://github.com/microsoft/winget-pkgs/tree/master/manifests) folder sorted on package/publisher's name, for example:
48+
49+
- 7zip can be found under [/manifests/7/7zip/7zip](https://github.com/microsoft/winget-pkgs/tree/master/manifests/7/7zip/7zip)
50+
- Adobe Acrobat Reader can be found under [/manifests/a/Adobe/Acrobat/Reader](https://github.com/microsoft/winget-pkgs/tree/master/manifests/a/Adobe/Acrobat/Reader)
51+
- Microsoft Bicep Cli can be found under [/manifests/m/Microsoft/Bicep](https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/Bicep)
52+
- Microsoft Azure Cli can be found under [/manifests/m/Microsoft/AzureCLI)](https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/AzureCLI)
53+
54+
## Prerequisites
55+
56+
- A GitHub account
57+
- I highly recommend to sign your commits. See [Using a Yubikey with GitHub for signing your commits \| ictstuff.info](https://ictstuff.info/using-a-Yubikey-with-github-for-signing-your-commits)
58+
- Windows 10 or Windows 11 machine with the winget client
59+
- The [wingetcreate](https://github.com/microsoft/winget-create) latest version installed.
60+
- `winget install wingetcreate`
61+
- Created a [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) of [winget-pkgs](https://github.com/microsoft/winget-pkgs) on GitHub.
62+
- Activated the [Windows Sandbox optional feature](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-overview) on your client machine.
63+
- I personally had some issues with the PowerShell command `Install-WindowsOptionalFeature`, so I used the GUI to install this:
64+
- Apps > Optional Features - More Windows Features
65+
- Check `Windows Sandbox` and reboot
66+
67+
## Steps
68+
69+
### Preparation and validation
70+
71+
For the Bicep Cli, I have subscribed to the repository's releases using the *watch* option - *custom* and selecting only `releases`
72+
73+
The instructions below are based on the release of [Bicep v0.27.1](https://github.com/Azure/bicep/releases/tag/v0.27.1)
74+
75+
- Check the open Pull requests on [microsoft/winget-pkgs on GitHub](https://github.com/microsoft/winget-pkgs/pulls), to make sure nobody has already submitted this package
76+
- Use this as a search filter: `is:pr is:open "bicep" in:title`
77+
- On the release page of Bicep v.0.18.4, find the `bicep-setup-win-x64.exe` package and copy the link for the next step
78+
79+
> **IMPORTANT:** Make sure you copy the `bicep-setup-win-64.exe` and not the bicep-win64.exe
80+
81+
### Create the winget manifest files for the installer package
82+
83+
- On your machine, open a PowerShell prompt and enter the following: `wingetcreate update --urls <link to bicep-setup-win-x64-package> --version <versionNumber> <Winget.PackageName>`, so in this case this should be:
84+
- `wingetcreate update --urls https://github.com/Azure/bicep/releases/download/v0.27.1/bicep-setup-win-x64.exe --version 0.27.1 Microsoft.Bicep`
85+
- This will create the following manifest files on your PC in the `C:\Users\<username>\manifests\m\Microsoft\Bicep\<0.xx.x>`
86+
- Microsoft.Bicep.installer.yaml
87+
- Microsoft.Bicep.locale.en-US.yaml
88+
- Microsoft.Bicep.yaml
89+
90+
### Modify the manifest files and store them in a new branch of your forked repository
91+
92+
- In GitHub, make sure your forked repository is synced
93+
- In VSCode, open your fork repository
94+
- Make sure you are in the main/master branch
95+
- Create a new branch from main/master.
96+
- In this case, I named the branch `feat-microsoft-bicep-v0.27.1`
97+
- Switch to the new branch and create a new folder called `manifests\m\Microsoft\Bicep\0.27.1`
98+
- Copy the 3 manifest files in this folder.
99+
- Modify the following:
100+
- `Microsoft.Bicep.installer.yaml`
101+
- Add a `ReleaseDate: 'yyyy-MM-dd` line with the release date of this version
102+
- `Microsoft.Bicep.locale.en-US.yaml`
103+
- Add a `ReleaseNotes` parameter and copy the details from the releasenotes page, for example:
104+
105+
```text
106+
ReleaseNotes: |-
107+
Highlights
108+
Bicep Team:
109+
- "publishSource" is now GA! (#13899)
110+
- Implement the spread ... operator, other new functions, and indices on lambdas (#13658)
111+
- Support completions inside object spread (#14000)
112+
- Normalize indenting for multi-line descriptions (#14013)
113+
- Default levels for linting rules finalized (#13847)
114+
- Permit validation for property access on union types (#14017)
115+
Bugs and Features
116+
Bicep Team:
117+
- Clarify on JSONRPC format (#13825)
118+
- Support --outdir param with build-params (#13890)
119+
- Create 'use-secure-value-for-secure-inputs' linter rule (#13905)
120+
- Add detailed validation for UDFs with UDTs (#14011)
121+
- Fix for stack overflow issue (#14049)
122+
- Check namespaces in prefer-interpolation linter rule (#14050)
123+
- Support codefix for missing Bicep params (#14012)
124+
- Formatting rule improvements (#13945)
125+
- Recognize common keywords for resource type completions (#13721)
126+
- Show full path of built JSON file so it's clickable in vscode (#13787)
127+
- Try to fix 13333 (#13788)
128+
- Make some minor improvements to resource filter keywords and add filter keyword support for resource snippets (#13731)
129+
- 13842 Bicep linter doesn't recognise managementGroupResourceId as a r… (#13889)
130+
```
131+
132+
- Add a `ReleaseNotesUrl` parameter, for example:
133+
- `ReleaseNotesUrl: https://github.com/Azure/bicep/releases/tag/v0.27.1`
134+
- Save the files and do not commit them yet.
135+
136+
### Validate the manifest files
137+
138+
- Open a PowerShell console session for this.
139+
- Validate your manifest files using winget cli.
140+
- **Be sure to validate the modified manifest files in your git branch, not the original location**
141+
- For example:
142+
- `winget validate X:\git\GitHub\MarcoJanse\winget-pkgs\manifests\m\Microsoft\Bicep\0.27.1\`
143+
- If everything is alright, it should say *`Manifest validation succeeded`*
144+
145+
### Test the manifest with Windows Sandbox
146+
147+
- Using PowerShell console session, navigate to your winget repository branch
148+
- **Make sure you are still in the branch with the new manifest files, and not in master/main branch.**
149+
- For example: `cd X:\git\github\MarcoJanse\winget-pkgs\Tools\`
150+
- Run the following to test the installation of Bicep using the manifest file in Windows Sandbox environment
151+
- `.\SandboxTest.ps1 ..\manifests\m\Microsoft\Bicep\0.27.1\`
152+
- This will list the output below, open a Windows Sandbox environment where you should see a successful installation of the Bicep Cli.
153+
- If you don't see a successful installation, you can check the winget log files on the sandbox to check for any solutions, try to install the package manually without winget and if that also fails, create a new issue in the source repository. In this case: [Azure/Bicep: Issues](https://github.com/Azure/bicep/issues)
154+
155+
```powershell
156+
> .\SandboxTest.ps1 ..\manifests\m\Microsoft\Bicep\0.27.1\
157+
--> Validating Manifest
158+
Manifest validation succeeded.
159+
160+
--> Checking dependencies
161+
--> Starting Windows Sandbox, and:
162+
- Mounting the following directories:
163+
- C:\Users\MarcoJanse\AppData\Local\Temp\SandboxTest as read-only
164+
- C:\git\GitHub\MarcoJanse\winget-pkgs\Tools as read-and-write
165+
- Installing WinGet
166+
- Configuring Winget
167+
- Installing the Manifest 0.27.1
168+
- Refreshing environment variables
169+
- Comparing ARP Entries
170+
```
171+
172+
Below is a screenshot of the sandbox and it's output if everything works.
173+
174+
![Windows Sandbox Winget installation of Microsoft.Bicep](../assets/images/post_2024-05_winget-windowsSandbox.png)
175+
176+
### Commit an push your changes
177+
178+
- In VSCode, in your branch commit the 3 files and enter a commit message:
179+
- For example: `feat: microsoft-bicep-v0.27.1`
180+
- Sync/pull changes to the remote repository.
181+
- Make sure you sync to your forked branch, not the original.
182+
183+
### Create a pull request to the microsoft/winget-pkgs repository
184+
185+
- Using GitHub, go to your forked winget-pkgs repository
186+
- Select your feature branch
187+
- Select your commit. (commit ahead)
188+
- You should automatically get a compare between your commit and the base repository (microsoft/winget-pkgs) on the master/main branch.
189+
- Verify the following:
190+
- base repository: `microsoft/winget-pkgs` and base: `master`
191+
- head repository: `MarcoJanse/winget-pkgs` and base: `feat-microsoft-bicep-v0.27.1`
192+
- *Able to merge* message is displayed
193+
- Select ***[Create Pull Request]***
194+
- Review all the questions and put an `x` between the brackets when it's okay.
195+
- Select ***[Submit]*** if everything is okay
196+
- This will start the pipelines for validation and approval. The pipeline validation should finish successfully within approximately an hour. The approval after successful validation depends on a reviewer with write access and could take several days.
197+
198+
You can find my original pull request for this here: [feat: microsoft-bicep-v0.27.1 #153499 \| winget-pkgs repo on Github.com](https://github.com/microsoft/winget-pkgs/pull/153499#issuecomment-2109492304)
199+
200+
### After successful merging of your pull request
201+
202+
After the pull request has been approved and merged into main
203+
204+
- Check if the package is available using `winget upgrade` and if so update using `winget upgrade microsoft.Bicep` or `winget upgrade --all`
205+
- If you just want to see your latest submitted package, with all the details - like the release notes - try `winget show microsoft.bicep`
206+
- On GitHub, go your your forked winget-pkgs repository and sync it with upstream.
207+
- Open the master branch of your localy cloned fork
208+
- Fetch and pull the updates into main
209+
- Back on GitHub, remove the old feature branch that has been merged
210+
- Back on your client do a `git fetch --prune`
211+
- This should list the local feature branch as deleted
212+
- Remove the local branch using `git branch -D feat-microsoft-bicep-v0_xx.x`
213+
- The `-D` is necessary as this branch has been merged in the upstream and not in your forked master branch.
214+
215+
## Closing notes
216+
217+
I hope you liked this post and learned a some things about winget, git, VSCode, Windows Sandbox and you enjoyed contributing to the community. You might do lots of people a favour if you contribute often.
218+
219+
## References
220+
221+
- [Use the winget tool to install and manage applications \| Microsoft Learn](https://learn.microsoft.com/en-us/windows/package-manager/winget/)
222+
- [Submit packages to Windows Package Manager \| Microsoft Learn](https://learn.microsoft.com/en-us/windows/package-manager/package/)
223+
- [winget-pkgs \| GitHub.com](https://github.com/microsoft/winget-pkgs)
224+
- [winget-create repository\| GitHub.com](https://github.com/microsoft/winget-create)
225+
- [Windows Sandbox optional feature \| Microsoft Learn](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-overview)
Loading

0 commit comments

Comments
 (0)