Skip to content

Commit 5690309

Browse files
committed
Support target version in update-codeql workflow
This commit adds an optional input to the "workflow_dispatch" trigger for the update-codeql.yml actions workflow in order to add support for using the workflow to upgarde to a target version (other than just latest) for the CodeQL CLI.
1 parent 3487416 commit 5690309

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

.github/workflows/update-codeql.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Update CodeQL CLI Dependencies
22

33
on:
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,40 @@ jobs:
3540
id: check-version
3641
env:
3742
GH_TOKEN: ${{ github.token }}
43+
TARGET_VERSION: ${{ 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+
if [ -n "${TARGET_VERSION}" ]; then
52+
# Use the manually specified target version
53+
latest_clean="${TARGET_VERSION#v}"
54+
echo "Using manually specified target version: ${latest_clean}"
4755
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
56+
# Validate the target version exists as a release
57+
if ! gh release view "v${latest_clean}" --repo github/codeql-cli-binaries --json tagName > /dev/null 2>&1; then
58+
echo "❌ Error: Target version v${latest_clean} does not exist in github/codeql-cli-binaries releases" >&2
59+
exit 1
60+
fi
61+
else
62+
# Get latest release from codeql-cli-binaries
63+
latest_tag=$(gh release list --repo github/codeql-cli-binaries --json 'tagName,isLatest' --jq '.[] | select(.isLatest == true) | .tagName')
5464
55-
latest_clean="${latest_tag#v}"
65+
# Validate that we found a latest release
66+
if [ -z "${latest_tag}" ]; then
67+
echo "❌ Error: Could not determine latest CodeQL CLI version from github/codeql-cli-binaries" >&2
68+
echo "No release marked as 'latest' was found. This may indicate an API issue or repository change." >&2
69+
exit 1
70+
fi
5671
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
72+
latest_clean="${latest_tag#v}"
6173
fi
74+
6275
echo "Current CodeQL CLI version: ${current_version}"
63-
echo "Latest CodeQL CLI version: ${latest_clean}"
76+
echo "Target CodeQL CLI version: ${latest_clean}"
6477
6578
if [ "${latest_clean}" != "${current_version}" ]; then
6679
echo "✅ Update available: ${current_version} → ${latest_clean}"

0 commit comments

Comments
 (0)