ImageMagick uses Advanced Installer to Automatically Publish the Latest Release to Winget Repository

Written by Dirk Lemstra · January 23rd, 2025 · 6min read

Starting with ImageMagick version 7.1.1-31, we’re leveraging Advanced Installer to automatically build and publish the latest release to the Windows Package Manager repository. This allows users to install ImageMagick using the Winget command line tool.

We now sign our installer with a Trusted Signing certificate, eliminating installation warnings while indicating that it’s signed by ImageMagick.

Creating the Release with Advanced Installer

We create the release using Advanced Installer, which supports the creation of various types of installers. For ImageMagick, we used it to create an MSIX installer.

Within a single GitHub action, we build the installer and use a Trusted Signing certificate to sign it.

Advanced Installer's capabilities streamline the entire process, from building to signing and publishing the installer.

For more details on how the installer was created and published, check out the story: ImageMagick MSIX Installer Now Secured with Trusted Signing via Advanced Installer story.

Creating the Winget Manifest

To get our application into the Windows Package Manager repository, we needed to create a manifest.

We used artifacts from the 7.1.1-30 release and the wingetcreate tool, which is available in the Windows Package Manager repository.

This tool allows the creation of a manifest that can be used to publish a package to the repository.

Here’s how we did it:

1. Install wingetcreate: We installed the tool with the command:

winget install wingetcreate

2. Create the Manifest using the command:

wingetcreate new

The tool first asked for the URL of the installer.

Create Winget Manifest with command line

After entering the URL, it downloaded the .msixbundle and parsed it.

3. Customize Settings: We were able to override some of the parsed settings. While we kept most of the default values, we had to adjust a few:

  • Changed the PackageIdentifier to ImageMagick.Q16-HDRI.
  • Updated the License to Apache-2.0 Derivative.
  • Modified the ShortDescription for clarity.
Customize your package manifest with command line

4. Preview the Manifest: The tool then showed a preview of the created manifest in the console.

Generate your manifest preview

Since our MSIX bundle contains both an x64 and arm64 installer, both architectures were included in the output. This is a significant advantage of the MSIX format, allowing users to install the correct architecture for their machine with a single installer.

Publishing the Manifest to Winget Repository

When it came time to publish our manifest to the Windows Package Manager repository, we took a few extra steps to ensure everything was perfect.

1. Initial Setup with wingetcreate

The wingetcreate command will ask if we would want to submit our manifest to the Windows Package Manager repository.

However, we wanted to add some additional information to the manifest and test it locally first, so we did not submit it right away.

This might be possible with the wingetcreate tool but we found it easier to edit this with a text editor instead.

Add information to package manifest with text editor

2. Editing the Manifest

After we made these changes, we made sure our manifest was correct and installed it locally to check if it was working.

The validation was done with:

winget validate --manifest manifests\i\ImageMagick\Q16-HDRI\7.1.1.30

After the successful validation, we tried a local installation with:

winget install --manifest manifests\i\ImageMagick\Q16-HDRI\7.1.1.30
Manifest validation with command line

3. Submitting the Manifest

We then created a pull request to add the manifest to the Windows Package Manager repository: https://github.com/microsoft/winget-pkgs/pull/148305 (Added ImageMagick version 7.1.1-30 that uses an MSIX installer instead). This pull request was merged, and the manifest was added to the repository.

How We Update the Manifest with Advanced Installer

After our initial pull request was merged, we can now update the manifest automatically whenever we create a new release.

This process is streamlined with the help of a GitHub action that triggers upon creating a new release. Here’s how we do it using wingetcreate:

publish_msix:
  name: 'Publish Msix'
  if: startsWith(github.ref, 'refs/tags/')
  needs:
    - version
    - create_release
  runs-on: windows-latest
  steps:
  - name: Install winget
    uses: Cyberboss/install-winget@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  - name: Install wingetcreate
    run: winget install wingetcreate --disable-interactivity --accept-source-agreements
  - name: Update manifest on winget
    run: wingetcreate update --submit --replace --token ${{ secrets.WINGET_TOKEN }} --urls https://github.com/ImageMagick/ImageMagick/releases/download/${{ needs.version.outputs.release }}/ImageMagick.Q16-HDRI.msixbundle --version ${{ needs.version.outputs.version }} ImageMagick.Q16-HDRI

This action installs wingetcreate and then updates the manifest with the new release.

Here’s a breakdown of the options used:

  • --submit: Submits the manifest to the Windows Package Manager repository through a pull request.
  • --replace: Replaces the existing manifest because we only want to have one manifest for the latest release.
  • --token: Used to create a pull request in the Windows Package Manager repository.
  • --urls Specifies the URL of the new installer that was created in the release.
  • --version Specifies the new version of ImageMagick.

The last argument is the PackageIdentifier, which specifies which manifest to update.

This is the same as the PackageIdentifier used when the manifest was initially created.

You might also notice that we use the GITHUB_TOKEN to install winget. At the time of writing, the winget tool was not yet available in the GitHub actions runners by default, but we hope this will change in the future.

Here’s an example of a recent pull request we created to update the manifest for the latest release: https://github.com/microsoft/winget-pkgs/pull/155169 (New version: ImageMagick.Q16-HDRI version 7.1.1.33).

Updating Our Federated Credentials for Smooth Releases

While running our workflow, we noticed that our federated credential needed to be fixed because we publish the release through a tag instead of a commit in the main branch.

To fix this, we added another federated credential specifically for tags.

Initially, we tried this with a wildcard (7*) for the tag, but it did not work. We then switched to 7.1.1-33 and that worked.

However, this approach required us to update the credential for every release, which wasn’t ideal.

To streamline the process, we decided to use an environment instead. We added an environment called "release" to our repository with a filter for specific tags:

Add an environment to repository

We then used this environment in our federated credential:

Use the created environment in Credentials

With this setup, we can now publish a release triggered by a tag, ensuring that the federated credential works seamlessly. This change simplifies our release process, making it more efficient and less prone to manual updates.

Installing ImageMagick with Winget

You can install ImageMagick with the following command:

winget install ImageMagick.Q16-HDRI

In the future, we plan to add Q16 and Q8 builds to the repository. We’ll keep them up to date using the same GitHub action that we use for the Q16-HDRI build.

Get in Touch

For more updates and insights on my work and development projects, follow me on X @MagickNET and connect with me on LinkedIn.

Written by
See author's page
Dirk Lemstra

Dirk Lemstra is an open-source maintainer and full-time developer based in Leeuwarden, The Netherlands. He maintains ImageMagick and its .NET Framework library, Magick.NET. Dirk also created @imagemagick/magic-wasm for TypeScript and is involved in other open-source image libraries. As a Microsoft MVP, GitHub Star and member of @SixLabors, Dirk is dedicated to enhancing image processing tools and helping others perform magic with images. Connect with Dirk on Bluesky and LinkedIn .

Comments: