Skip to content

GitHub Action for installing the wonderful build tool, CMake

License

Notifications You must be signed in to change notification settings

ssrobins/install-cmake

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Install CMake

This GitHub Action installs CMake so you can use the latest release, latest release candidate, or a specific version. If the requested version is already installed, the install is skipped. CMake is already installed and regularly updated as part of the provided runner images so it's most useful in the following situations:

  • You want to be on the latest CMake at all times
  • You want to stay on a specific version of CMake at all times
  • You want to use a release candidate for early access to new features or to help with testing
  • You maintain your own runner and you want a way to install CMake

Usage

Available inputs are described here.

Install the latest version of CMake with one line:

- uses: ssrobins/install-cmake@v1

Same as above, but with a custom step name:

- name: Install CMake
  uses: ssrobins/install-cmake@v1

Allow the latest CMake install to be a release candidate, if available:

- name: Install CMake
  uses: ssrobins/install-cmake@v1
  with:
    release-candidate: true

Use version to specify a particular version of CMake in the form of 3.24.3 or 3.25.0-rc4 for release candidates. NOTE: Currently, only 3.20.0 or higher are supported, but that can be changed if there's a need for it.

- name: Install CMake
  uses: ssrobins/install-cmake@v1
  with:
    version: 3.24.3

Add continue-on-error: true if you don't want a failure of the action to fail the whole pipeline.

- name: Install CMake
  uses: ssrobins/install-cmake@v1
  continue-on-error: true

To always have the latest code from this action and are ok with the possibility of API breaks, set the version to main:

- uses: ssrobins/install-cmake@main

Contributing

I want this to be useful to the whole community so if you have an idea, please post an issue or a pull request. I'll do my best to respond in a few days. All I ask for is the following:

  • Clearly articulate the goal of a change
  • Make sure PR checks pass
  • Be nice!

Under-the-hood

This GitHub Action is a composite action. Here are all the parts:

The CMake install itself is simply a download and extraction of the platform-specific tar/zip archive into the GitHub Actions workspace so it's only present in that particular actions run and won't affect any existing CMake installations on the machine. In order for the cmake command to use this local install, it outputs the path to the $GITHUB_PATH environment file so it will ultimately be added to the PATH environment variable. More info in the GitHub documentation.

The determination of the latest release and release candidate is done with a web scraping of https://cmake.org/download/. Then, it's downloaded from https://github.com/Kitware/CMake/releases using the established naming pattern that's been around since 3.20.0, which is why that's the current minimum supported version (for now, at least).

If either cmake.org goes down or the install archive pattern changes, this action will break. Using continue-on-error: true in the action mitigates the impact, as long as the runner has an existing CMake installation that'll work with your build.

Inside scoop

I've actually been using this action unpublished in a few repos since early 2021 to install the CMake release candidate for hobby projects. One day, my GitHub Actions checks broke on the first CMake 3.25 release candidate, which led me to log a bug that ended up getting fixed. After that, I realized this could be a useful action for the awesome CMake community so I looked into publishing it to the marketplace.

About

GitHub Action for installing the wonderful build tool, CMake

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages