A basic containerized 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 some winget manifests up to date. I only tested on the manifests I use. You may 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 image 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 existing docker image (recommended) or use the dockerfile to build image then you can skip the other depedencies.
If you want to test the script localy (useful for debug) 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
For a lot of reasons, it is more convient (at least for me) to "containerize" a script rather than running it as it is.
The docker image can be run using 5 parameters (passed as runtime ENV
settings) :
<MAINTAINER_REPO>
: The GitHub project where your winget-pkgs fork is located, in the format githubName/winget-pkgs-fork.<PUBLISHER_REPO>
: The GitHub project where the package releases are located, in the format githubName/project_name.<WINGET_PACKAGE>
: The name of the package (as declared in winget manifest) that you want to track and update, in the format Publisher.PackageName.<GIT_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 or if you want to also create manifest for all past releases. Default value if absent is latest for only upcoming versions. Use value full for parsing "all the past".
-
Get the latest docker image from ghcr.io
docker pull ghcr.io/senacra/wingetmus:v0.2.0
-
Or, alternatively, build the docker image from sources
docker build -t senacra/wingetmus:v0.2.0 .
-
Run the docker container.
sudo docker run -e MAINTAINER_REPO=... -e PUBLISHER_REPO=... -e WINGET_PACKAGE=... -e GIT_TOKEN=... -e MODE=latest senacra/wingetmus:v0.2.0
The update_manifest.sh basically takes the exact same parameters as the docker.
For example :
./update_manifest.sh myName/winget-pkgs-fork AwesomePublisher/TopPackage AwesomePublisher.TopPackage this_should_look_random latest
Documentation to be done
- V0.1.0 based on few tested manifests.
- Make it generic by getting download URLs directly using Github API.
- Allow a configurable installer download source (if not github).
- Add documentation on the "cron" and other schedulling methods.
- Add a docker compose file.
- Add a -h and errors management for script.
- Maybe update the image to manage list of packages to track.
Well this is just a very basic script put inside a container, and probably most of you will prefer to include winget in publishing CI when possible. But in any cases contributions/questions/suggestions are welcome :)
Distributed under the AGPLv3.0. See LICENSE.txt
for more information.