1+ name : " Update the CodeQL CLI dependencies"
2+
3+ on :
4+ workflow_dispatch :
5+ # nightly runs to update the CodeQL CLI dependencies
6+ schedule :
7+ - cron : ' 30 0 * * *'
8+
9+ jobs :
10+ update-codeql :
11+ name : Update CodeQL CLI dependencies
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+
18+ - name : Check latest CodeQL CLI version and update qlt.conf.json
19+ id : check-version
20+ run : |
21+ echo "Checking latest CodeQL CLI version"
22+ current_version=$(jq .CodeQLCLI qlt.conf.json -r)
23+ latest_version=$(curl -s https://api.github.com/repos/github/codeql-cli-binaries/releases/latest | jq -r .tag_name)
24+ echo "Current CodeQL CLI version: $current_version"
25+ echo "Latest CodeQL CLI version: $latest_version"
26+
27+ # Remove 'v' prefix if present for comparison with current version
28+ latest_clean=$(echo "$latest_version" | sed 's/^v//')
29+
30+ if [ "$latest_clean" != "$current_version" ]; then
31+ echo "Updating CodeQL CLI from $current_version to $latest_clean"
32+ echo "update_needed=true" >> $GITHUB_OUTPUT
33+ echo "latest_version=$latest_clean" >> $GITHUB_OUTPUT
34+ echo "latest_version_tag=$latest_version" >> $GITHUB_OUTPUT
35+
36+ # Update qlt.conf.json with all properties
37+ echo "Updating qlt.conf.json with all properties for version $latest_clean"
38+ jq --arg cli_version "$latest_clean" \
39+ --arg std_lib "codeql-cli/$latest_version" \
40+ --arg bundle "codeql-bundle-$latest_version" \
41+ '.CodeQLCLI = $cli_version | .CodeQLStandardLibrary = $std_lib | .CodeQLCLIBundle = $bundle' \
42+ qlt.conf.json > qlt.conf.json.tmp && mv qlt.conf.json.tmp qlt.conf.json
43+
44+ echo "Updated qlt.conf.json contents:"
45+ cat qlt.conf.json
46+ else
47+ echo "CodeQL CLI is already up-to-date at version $current_version."
48+ echo "update_needed=false" >> $GITHUB_OUTPUT
49+ fi
50+
51+ - name : Install QLT
52+ if : steps.check-version.outputs.update_needed == 'true'
53+ id : install-qlt
54+ uses : advanced-security/codeql-development-toolkit/.github/actions/install-qlt@main
55+ with :
56+ qlt-version : ' latest'
57+ add-to-path : true
58+
59+ - name : Install CodeQL
60+ if : steps.check-version.outputs.update_needed == 'true'
61+ id : install-codeql
62+ shell : bash
63+ run : |
64+ echo "Installing CodeQL"
65+ qlt codeql run install
66+ echo "-----------------------------"
67+ echo "CodeQL Home: $QLT_CODEQL_HOME"
68+ echo "CodeQL Binary: $QLT_CODEQL_PATH"
69+
70+ - name : Create Pull Request
71+ if : steps.check-version.outputs.update_needed == 'true'
72+ uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
73+ with :
74+ title : " Upgrade CodeQL CLI dependency to ${{ steps.check-version.outputs.latest_version_tag }}"
75+ body : |
76+ This PR upgrades the CodeQL CLI version to ${{ steps.check-version.outputs.latest_version_tag }}.
77+
78+ **Changes made:**
79+ - Updated `CodeQLCLI` to `${{ steps.check-version.outputs.latest_version }}`
80+ - Updated `CodeQLStandardLibrary` to `codeql-cli/${{ steps.check-version.outputs.latest_version_tag }}`
81+ - Updated `CodeQLCLIBundle` to `codeql-bundle-${{ steps.check-version.outputs.latest_version_tag }}`
82+ commit-message : " Upgrade CodeQL CLI dependency to ${{ steps.check-version.outputs.latest_version_tag }}"
83+ delete-branch : true
84+ branch : " codeql/upgrade-to-${{ steps.check-version.outputs.latest_version_tag }}"
0 commit comments