A basic shell script to monitor 3rd party repo and create winget manifest when new release is up.
Important
This script is the one I use to keep RPTools.MapTool manifests up to date. Some parts of the script are hard coded for this usecase. You will need some (minor) adaptation to use it for other component.
I was looking for an easy way to make some winget-pkgs manifest update automated. As I maintain these manifests without beeing the publisher, I do not have access to publisher CI - which is the easiest way to perform this.
So I created a small script to do this step, then created a docker image to perform this action and finaly setup a cron job to run this image.
This script checks if there is a new release of a monitored package for which there is not yet a winget pull request, and uses Komac CLI to create one (example).
In any cases the following 2 steps should be done before using project :
- Generate an access token on your GitHub account to be able to run Komac.
- Create a fork from winget-pkgs to handle your pull requests for manifests - Also take care to validate all requirements to be able to contribute to Microsoft repositories.
If you want to use the dockerfile to build an image running the script then you can skip the other depedencies.
If you want to run the script localy then you need to be on Linux or WSL if using Windows (as this is an sh script) and to install the following distribution dependencies :
- Basic dependencies (Example on Ubuntu)
apt-get update && apt-get install -y --no-install-recommends --no-install-suggests git wget curl jq ca-certificates
- Install Komac (Example on Ubuntu)
wget https://github.com/russellbanks/Komac/releases/download/v2.10.1/komac_2.10.1-1_amd64.deb dpkg -i komac_2.10.1-1_amd64.deb
- Clone the repo
git clone https://github.com/senacra/wingetmus.git
- Adapt the script (at least regex for version parsing and URL for downloading) to match your needs.
The update_manifest.sh script can be called using 4 parameters :
githubName/winget-pkgs-fork
: The GitHub project where your winget-pkgs fork is located.Publisher.PackageName
: The name of the package (as declared in winget manifest) that you want to track and update.token
: Your PAT for your GitHub account with the winget-pkgs fork.- (opt)
mode
: a mode string to know if you want to track only for upcomming releases (default) or if you want to also create manifest for all past releases (use full).
For example :
./update_manifest.sh myName/winget-pkgs-fork AwesomePublisher.TopPackage this_should_look_random
For a lot of reasons, it is more convient (at least for me) to "dockerize" a script rather than running it as it is. Once you have updated the script to match your needs, and tested it localy, you can proceed as follow :
-
Adapt the Dockerfile file to put the good arguments (last CMD line) - The give example is used for RPTools.MapTool package.
-
Build the docker image
docker build -t manifest-updater:v1 .
-
Run the docker container.
sudo docker run -e GIT_TOKEN=<token> manifest-updater:v1
Documentation to be done
- V1 hardcoded to handle RPTools.MapTool manifests.
- Make it generic by getting download URLs directly using Github API.
- Allow a configurable regex for version.
- Add documentation on the "cron" and other schedulling methods.
- Maybe update the image to add a light web service to manage list of packages to track.
Well this is just a very basic script, and probably most of you will prefer to include winget in publishing CI when possible, or to use existing GitHub action plugins. But in any cases contributions/questions/suggestions are welcome :)
Distributed under the AGPLv3.0. See LICENSE.txt
for more information.