@@ -2,6 +2,11 @@ name: Update CodeQL CLI Dependencies
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ target_version :
7+ description : ' Target CodeQL CLI version (e.g. vX.Y.Z). Leave empty to use the latest available CodeQL CLI release.'
8+ required : false
9+ type : string
510 # Nightly check for new CodeQL CLI releases
611 schedule :
712 - cron : ' 30 5 * * *'
@@ -35,32 +40,43 @@ jobs:
3540 id : check-version
3641 env :
3742 GH_TOKEN : ${{ github.token }}
43+ TARGET_VERSION : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_version || '' }}
3844 run : |
3945 echo "Checking latest CodeQL CLI version..."
4046
4147 # Read current version from .codeql-version (stores vX.Y.Z)
4248 current_version_raw=$(cat .codeql-version | tr -d '[:space:]')
4349 current_version="${current_version_raw#v}"
4450
45- # Get latest release from codeql-cli-binaries
46- latest_tag =$(gh release list --repo github/codeql-cli-binaries --json 'tagName,isLatest' --jq '.[] | select(.isLatest == true) | .tagName ')
51+ # Trim whitespace from target version input
52+ TARGET_VERSION =$(echo "${TARGET_VERSION}" | tr -d '[:space:] ')
4753
48- # Validate that we found a latest release
49- if [ -z "${latest_tag}" ]; then
50- echo "❌ Error: Could not determine latest CodeQL CLI version from github/codeql-cli-binaries" >&2
51- echo "No release marked as 'latest' was found. This may indicate an API issue or repository change." >&2
52- exit 1
53- fi
54+ if [ -n "${TARGET_VERSION}" ]; then
55+ # Use the manually specified target version
56+ latest_clean="${TARGET_VERSION#v}"
57+ echo "Using manually specified target version: ${latest_clean}"
5458
55- latest_clean="${latest_tag#v}"
59+ # Validate the target version exists as a release
60+ if ! gh release view "v${latest_clean}" --repo github/codeql-cli-binaries --json tagName > /dev/null 2>&1; then
61+ echo "❌ Error: Target version v${latest_clean} does not exist in github/codeql-cli-binaries releases" >&2
62+ exit 1
63+ fi
64+ else
65+ # Get latest release from codeql-cli-binaries
66+ latest_tag=$(gh release list --repo github/codeql-cli-binaries --json 'tagName,isLatest' --jq '.[] | select(.isLatest == true) | .tagName')
5667
57- if [ -z "${latest_tag}" ]; then
58- echo "❌ ERROR: Failed to determine latest CodeQL CLI release. 'gh release list' returned no results or no release is marked as latest." >&2
59- echo "update_needed=false" >> $GITHUB_OUTPUT
60- exit 1
68+ # Validate that we found a latest release
69+ if [ -z "${latest_tag}" ]; then
70+ echo "❌ Error: Could not determine latest CodeQL CLI version from github/codeql-cli-binaries" >&2
71+ echo "No release marked as 'latest' was found. This may indicate an API issue or repository change." >&2
72+ exit 1
73+ fi
74+
75+ latest_clean="${latest_tag#v}"
6176 fi
77+
6278 echo "Current CodeQL CLI version: ${current_version}"
63- echo "Latest CodeQL CLI version: ${latest_clean}"
79+ echo "Target CodeQL CLI version: ${latest_clean}"
6480
6581 if [ "${latest_clean}" != "${current_version}" ]; then
6682 echo "✅ Update available: ${current_version} → ${latest_clean}"
0 commit comments