Skip to content

Commit f346a37

Browse files
authored
[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
1 parent d453d10 commit f346a37

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

images/ubuntu/scripts/build/install-codeql-bundle.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,23 @@
77
# Source the helpers for use with the script
88
source $HELPER_SCRIPTS/install.sh
99

10+
# Retrieve the latest major version of the CodeQL Action to use in the base URL for downloading the bundle.
11+
releases=$(curl -s "https://api.github.com/repos/github/codeql-action/releases")
12+
13+
# 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.
14+
codeql_action_latest_major_version=$(echo "$releases" |
15+
jq -r '.[].tag_name' |
16+
grep -E '^v[0-9]' |
17+
sort -nr |
18+
head -n 1 |
19+
sed -E 's/^v([0-9]+).*/\1/')
20+
if [ -z "$codeql_action_latest_major_version" ]; then
21+
echo "Error: Unable to find the latest major version of the CodeQL Action."
22+
exit 1
23+
fi
24+
1025
# Retrieve the CLI version of the latest CodeQL bundle.
11-
base_url="$(curl -fsSL https://raw.githubusercontent.com/github/codeql-action/v3/src/defaults.json)"
26+
base_url="$(curl -fsSL https://raw.githubusercontent.com/github/codeql-action/v"$codeql_action_latest_major_version"/src/defaults.json)"
1227
bundle_version="$(echo "$base_url" | jq -r '.cliVersion')"
1328
bundle_tag_name="codeql-bundle-v$bundle_version"
1429

0 commit comments

Comments
 (0)