From f346a37e5c333b9dcd7c0db487952c6be3fb4dac Mon Sep 17 00:00:00 2001 From: Angela P Wen Date: Wed, 23 Apr 2025 16:40:39 -0700 Subject: [PATCH] [Ubuntu] Always use the latest major version of CodeQL Action (#11931) * [Ubuntu] Update default CodeQL major version to v3 * [Ubuntu] use the latest CodeQL Action major version Instead of hardcoding it! * Add missing `v` to CodeQL bundle URL --- .../scripts/build/install-codeql-bundle.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/images/ubuntu/scripts/build/install-codeql-bundle.sh b/images/ubuntu/scripts/build/install-codeql-bundle.sh index ddce66539..37bd92765 100644 --- a/images/ubuntu/scripts/build/install-codeql-bundle.sh +++ b/images/ubuntu/scripts/build/install-codeql-bundle.sh @@ -7,8 +7,23 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/install.sh +# Retrieve the latest major version of the CodeQL Action to use in the base URL for downloading the bundle. +releases=$(curl -s "https://api.github.com/repos/github/codeql-action/releases") + +# Get the release tags starting with v[0-9] and sort them in descending order, then parse the first one to get the major version. +codeql_action_latest_major_version=$(echo "$releases" | + jq -r '.[].tag_name' | + grep -E '^v[0-9]' | + sort -nr | + head -n 1 | + sed -E 's/^v([0-9]+).*/\1/') +if [ -z "$codeql_action_latest_major_version" ]; then + echo "Error: Unable to find the latest major version of the CodeQL Action." + exit 1 +fi + # Retrieve the CLI version of the latest CodeQL bundle. -base_url="$(curl -fsSL https://raw.githubusercontent.com/github/codeql-action/v3/src/defaults.json)" +base_url="$(curl -fsSL https://raw.githubusercontent.com/github/codeql-action/v"$codeql_action_latest_major_version"/src/defaults.json)" bundle_version="$(echo "$base_url" | jq -r '.cliVersion')" bundle_tag_name="codeql-bundle-v$bundle_version"