|
6 | 6 |
|
7 | 7 | source $HELPER_SCRIPTS/install.sh |
8 | 8 |
|
9 | | -# Retrieve the CLI versions and bundle tags of the latest two CodeQL bundles. |
| 9 | +# Retrieve the CLI version of the latest CodeQL bundle. |
10 | 10 | base_url="$(curl -fsSL https://raw.githubusercontent.com/github/codeql-action/v2/src/defaults.json)" |
11 | | -codeql_tag_name="$(echo "$base_url" | jq -r '.bundleVersion')" |
12 | | -codeql_cli_version="$(echo "$base_url" | jq -r '.cliVersion')" |
13 | | -prior_codeql_tag_name="$(echo "$base_url" | jq -r '.priorBundleVersion')" |
14 | | -prior_codeql_cli_version="$(echo "$base_url" | jq -r '.priorCliVersion')" |
| 11 | +bundle_version="$(echo "$base_url" | jq -r '.cliVersion')" |
| 12 | +bundle_tag_name="codeql-bundle-v$bundle_version" |
15 | 13 |
|
16 | | -# Compute the toolcache version number for each bundle. This is either `x.y.z` or `x.y.z-YYYYMMDD`. |
17 | | -if [[ "${codeql_tag_name##*-}" == "v"* ]]; then |
18 | | - # Tag name of the format `codeql-bundle-vx.y.z`, where x.y.z is the CLI version. |
19 | | - # We don't need to include the tag name in the toolcache version number because it's derivable |
20 | | - # from the CLI version. |
21 | | - codeql_bundle_version="$codeql_cli_version" |
22 | | -elif [[ "${codeql_tag_name##*-}" =~ ^[0-9]+$ ]]; then |
23 | | - # Tag name of the format `codeql-bundle-YYYYMMDD`. |
24 | | - # We need to include the tag name in the toolcache version number because it can't be derived |
25 | | - # from the CLI version. |
26 | | - codeql_bundle_version="$codeql_cli_version-${codeql_tag_name##*-}" |
27 | | -else |
28 | | - echo "Unrecognised current CodeQL bundle tag name: $codeql_tag_name." \ |
29 | | - "Could not compute toolcache version number." |
30 | | - exit 1 |
31 | | -fi |
32 | | -if [[ "${prior_codeql_tag_name##*-}" == "v"* ]]; then |
33 | | - # Tag name of the format `codeql-bundle-vx.y.z`, where x.y.z is the CLI version. |
34 | | - # We don't need to include the tag name in the toolcache version number because it's derivable |
35 | | - # from the CLI version. |
36 | | - prior_codeql_bundle_version="$prior_codeql_cli_version" |
37 | | -elif [[ "${prior_codeql_tag_name##*-}" =~ ^[0-9]+$ ]]; then |
38 | | - # Tag name of the format `codeql-bundle-YYYYMMDD`. |
39 | | - # We need to include the tag name in the toolcache version number because it can't be derived |
40 | | - # from the CLI version. |
41 | | - prior_codeql_bundle_version="$prior_codeql_cli_version-${prior_codeql_tag_name##*-}" |
42 | | -else |
43 | | - echo "Unrecognised prior CodeQL bundle tag name: $prior_codeql_tag_name." \ |
44 | | - "Could not compute toolcache version number." |
45 | | - exit 1 |
46 | | -fi |
| 14 | +echo "Downloading CodeQL bundle $bundle_version..." |
| 15 | +# Note that this is the all-platforms CodeQL bundle, to support scenarios where customers run |
| 16 | +# different operating systems within containers. |
| 17 | +download_with_retries "https://github.com/github/codeql-action/releases/download/$bundle_tag_name/codeql-bundle.tar.gz" "/tmp" "codeql-bundle.tar.gz" |
| 18 | +codeql_archive="/tmp/codeql-bundle.tar.gz" |
47 | 19 |
|
48 | | -# Download and name both CodeQL bundles. |
49 | | -codeql_bundle_versions=("${codeql_bundle_version}" "${prior_codeql_bundle_version}") |
50 | | -codeql_tag_names=("${codeql_tag_name}" "${prior_codeql_tag_name}") |
| 20 | +codeql_toolcache_path="$AGENT_TOOLSDIRECTORY/CodeQL/$bundle_version/x64" |
| 21 | +mkdir -p "$codeql_toolcache_path" |
51 | 22 |
|
52 | | -for index in "${!codeql_bundle_versions[@]}"; do |
53 | | - bundle_version="${codeql_bundle_versions[$index]}" |
54 | | - bundle_tag_name="${codeql_tag_names[$index]}" |
55 | | - |
56 | | - echo "Downloading CodeQL bundle $bundle_version..." |
57 | | - download_with_retries "https://github.com/github/codeql-action/releases/download/$bundle_tag_name/codeql-bundle.tar.gz" "/tmp" "codeql-bundle.tar.gz" |
58 | | - codeql_archive="/tmp/codeql-bundle.tar.gz" |
| 23 | +echo "Unpacking the downloaded CodeQL bundle archive..." |
| 24 | +tar -xzf "$codeql_archive" -C "$codeql_toolcache_path" |
59 | 25 |
|
60 | | - codeql_toolcache_path="$AGENT_TOOLSDIRECTORY/CodeQL/$bundle_version/x64" |
61 | | - mkdir -p "$codeql_toolcache_path" |
| 26 | +# Touch a file to indicate to the CodeQL Action that this bundle shipped with the toolcache. This is |
| 27 | +# to support overriding the CodeQL version specified in defaults.json on GitHub Enterprise. |
| 28 | +touch "$codeql_toolcache_path/pinned-version" |
62 | 29 |
|
63 | | - echo "Unpacking the downloaded CodeQL bundle archive..." |
64 | | - tar -xzf "$codeql_archive" -C "$codeql_toolcache_path" |
65 | | - |
66 | | - # We only pin the latest version in the toolcache, to support overriding the CodeQL version specified in defaults.json on GitHub Enterprise. |
67 | | - if [[ "$bundle_version" == "$codeql_bundle_version" ]]; then |
68 | | - touch "$codeql_toolcache_path/pinned-version" |
69 | | - fi |
70 | | - |
71 | | - # Touch a file to indicate to the toolcache that setting up CodeQL is complete. |
72 | | - touch "$codeql_toolcache_path.complete" |
73 | | -done |
| 30 | +# Touch a file to indicate to the toolcache that setting up CodeQL is complete. |
| 31 | +touch "$codeql_toolcache_path.complete" |
0 commit comments