Skip to content

Add install cmake action - #310

Merged
etcwilde merged 2 commits into
swiftlang:mainfrom
etcwilde:ewilde/install-cmake-action
Aug 21, 2026
Merged

Add install cmake action#310
etcwilde merged 2 commits into
swiftlang:mainfrom
etcwilde:ewilde/install-cmake-action

Conversation

@etcwilde

Copy link
Copy Markdown
Member

Adding an action to install a specific version of CMake. The version is verified against a hash before being unpacked and installed.

I have verified this with several versions of CMake on Linux.
I haven't had a setup with macOS or Windows to test against yet, but the GitHub actions docs say that bash is available on all platforms (as is powershell, but I don't want to write powershell) with the note

When specifying a bash shell on Windows, the bash shell included with Git for Windows is used.

The link format is consistent, with cmake-<version>-<arch>.(tar.gz|.zip). There are OS-specific installer-based packages, but the tarballs and zips are easier to unpack and verify reliably.

@etcwilde
etcwilde requested a review from a team as a code owner August 18, 2026 22:54
@etcwilde etcwilde added the github_actions Pull requests that update GitHub Actions code label Aug 18, 2026
Comment thread .github/actions/install-cmake/readme.md Outdated
@etcwilde
etcwilde force-pushed the ewilde/install-cmake-action branch from c30f5aa to 062f1a7 Compare August 18, 2026 23:08
@etcwilde

Copy link
Copy Markdown
Member Author
-#!/bin/bash
+#!/usr/bin/env bash

... really? That's not even part of the license.

@etcwilde
etcwilde force-pushed the ewilde/install-cmake-action branch from 062f1a7 to c4e323a Compare August 18, 2026 23:10
@FranzBusch

Copy link
Copy Markdown
Member

Where do you see this going? I opened a PR a few months ago to add Cmake based workflows which we are using in the Swift Server world #229? Curious to hear your thoughts how this PR might relate to my PR.

@etcwilde

Copy link
Copy Markdown
Member Author

Where do you see this going? I opened a PR a few months ago to add Cmake based workflows which we are using in the Swift Server world #229? Curious to hear your thoughts how this PR might relate to my PR.

I see this allowing folks to install specific version(s) of CMake and then calling it. It's meant to compose with existing workflows by exposing the cmake binary as an output of the action.

e.g.

The referenced PR only appears to work on apt-based Linux distros, rewrites the CMakeLists.txt, and then tries to run the build. To update that PR with this action in place, you could drop the which cmake || apt -yq install cmake portion and use it instead.

      - name: CMake build
        run: |
          which curl cmake ninja || apt -q update
          which curl || apt -yq install curl
          which cmake || apt -yq install cmake
          which ninja || apt -yq install ninja-build
          TARGET_DIRECTORY="${{ 

Then reference the output of the action with something like

 - name: Run CMake
     shell: bash
     env:
         CMAKE: ${{ steps.install-cmake.outputs.ctest }}
     run: |
       "$CMAKE" -G Ninja -B build -S .
...

Comment thread .github/actions/install-cmake/install-cmake.sh Outdated
@etcwilde
etcwilde force-pushed the ewilde/install-cmake-action branch from c4e323a to a3fc132 Compare August 19, 2026 16:24
@etcwilde
etcwilde requested a review from shahmishal August 19, 2026 16:25
@shahmishal

Copy link
Copy Markdown
Member

Please add a workflow to test this part of PR testing.

Adding an action to install a specific version of CMake. The version is
verified against a hash before being unpacked and installed.
@etcwilde
etcwilde force-pushed the ewilde/install-cmake-action branch from a3fc132 to 0858150 Compare August 19, 2026 17:22
Verify that we can download CMake and that we get the expected version.
@etcwilde
etcwilde force-pushed the ewilde/install-cmake-action branch from 0858150 to 3f2f66a Compare August 19, 2026 17:30
@etcwilde

Copy link
Copy Markdown
Member Author

@shahmishal and I talked offline about also adding a default workflow that projects can use directly. I will put that up in a separate PR. I'd like to unblock Swift Format and Swift Foundation who are blocked after bumping Swift Syntax to requiring CMake 3.29.


# 3. Download
echo "==> Downloading ${ARCHIVE_URL}..."
curl -fsSL --retry 3 -o "${ARCHIVE_PATH}" "${ARCHIVE_URL}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the future and digging through the action marketplace, migrating this script to Javascript should let us drop all of the dependencies since nodejs is supposed to always be available.

@etcwilde
etcwilde merged commit f8c5dc1 into swiftlang:main Aug 21, 2026
199 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants