Skip to content

Commit e1b245d

Browse files
committed
Setup copilot-setup-steps actions workflow
1 parent cdfeba9 commit e1b245d

File tree

4 files changed

+102
-4
lines changed

4 files changed

+102
-4
lines changed

.codeql-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v2.25.0
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Copilot Setup Steps'
2+
3+
on:
4+
# Automatically run the setup steps when an associated workflow is changed.
5+
push:
6+
paths:
7+
- '.codeql-version'
8+
- '.github/workflows/copilot-setup-steps.yml'
9+
- '.node-version'
10+
- '**/codeql-pack.yml'
11+
- '**/codeql-pack.lock.yml'
12+
- '**/qlpack.yml'
13+
- 'extractors/cds/tools/package.json'
14+
- 'extractors/cds/tools/package-lock.json'
15+
pull_request:
16+
paths:
17+
- '.codeql-version'
18+
- '.github/workflows/copilot-setup-steps.yml'
19+
- '.node-version'
20+
- '**/codeql-pack.yml'
21+
- '**/codeql-pack.lock.yml'
22+
- '**/qlpack.yml'
23+
- 'extractors/cds/tools/package.json'
24+
- 'extractors/cds/tools/package-lock.json'
25+
26+
jobs:
27+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
28+
copilot-setup-steps:
29+
permissions:
30+
contents: read
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Copilot Setup - Checkout code
35+
uses: actions/checkout@v6
36+
37+
- name: Copilot Setup - Setup Node.js
38+
uses: actions/setup-node@v6
39+
with:
40+
cache: 'npm'
41+
cache-dependency-path: 'extractors/cds/tools/package-lock.json'
42+
node-version-file: '.node-version'
43+
44+
- name: Copilot Setup - Install CDS extractor dependencies
45+
working-directory: extractors/cds/tools
46+
run: npm ci
47+
48+
- name: Copilot Setup - Setup CodeQL environment
49+
uses: advanced-security/codeql-development-mcp-server/.github/actions/setup-codeql-environment@main
50+
with:
51+
install-language-runtimes: false
52+
53+
- name: Copilot Setup - Install CodeQL packs
54+
run: ./scripts/install-packs.sh

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

scripts/update-release-version.sh

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set -euo pipefail
2727
## that reference other packs in this repository (e.g., ^X.Y.Z constraints).
2828
## - qlt.conf.json (CodeQLCLI, CodeQLStandardLibrary, CodeQLCLIBundle)
2929
## using the base version (X.Y.Z) derived by stripping any pre-release suffix.
30+
## - .codeql-version (vX.Y.Z, kept in sync with qlt.conf.json CodeQLCLI)
3031
##
3132
## Usage:
3233
## ./scripts/update-release-version.sh <new-version>
@@ -182,8 +183,24 @@ check_versions() {
182183
fi
183184
fi
184185

186+
## Also check .codeql-version consistency (must match qlt.conf.json CodeQLCLI with v prefix)
187+
local codeql_version_file="${REPO_ROOT}/.codeql-version"
188+
if [[ -f "${codeql_version_file}" ]]; then
189+
local codeql_file_version
190+
codeql_file_version=$(tr -d '[:space:]' < "${codeql_version_file}")
191+
local check_base="${expected_version:-${first_version}}"
192+
check_base="${check_base%%-*}"
193+
local expected_codeql_version="v${check_base}"
194+
if [[ "${codeql_file_version}" == "${expected_codeql_version}" ]]; then
195+
echo " ✅ .codeql-version: ${codeql_file_version}"
196+
else
197+
echo " ❌ .codeql-version: ${codeql_file_version} (expected ${expected_codeql_version})"
198+
all_consistent=false
199+
fi
200+
fi
201+
185202
echo ""
186-
echo "Checked ${file_count} version-bearing files + qlt.conf.json."
203+
echo "Checked ${file_count} version-bearing files + qlt.conf.json + .codeql-version."
187204

188205
if [[ "${all_consistent}" == true ]]; then
189206
if [[ -n "${expected_version}" ]]; then
@@ -257,6 +274,30 @@ update_qlt_config() {
257274
echo " ✅ qlt.conf.json: CodeQLCLI -> ${base_version}"
258275
}
259276

277+
## Update .codeql-version file (kept in sync with qlt.conf.json CodeQLCLI)
278+
## The file contains the version with a 'v' prefix, e.g. v2.25.0
279+
update_codeql_version_file() {
280+
local new_version="$1"
281+
local dry_run="${2:-false}"
282+
local codeql_version_file="${REPO_ROOT}/.codeql-version"
283+
284+
# Derive the base version by stripping any pre-release suffix
285+
local base_version="${new_version%%-*}"
286+
287+
if [[ ! -f "${codeql_version_file}" ]]; then
288+
echo "WARNING: .codeql-version not found, skipping" >&2
289+
return 0
290+
fi
291+
292+
if [[ "${dry_run}" == true ]]; then
293+
echo " [DRY RUN] .codeql-version: -> v${base_version}"
294+
return 0
295+
fi
296+
297+
printf 'v%s\n' "${base_version}" > "${codeql_version_file}"
298+
echo " ✅ .codeql-version: -> v${base_version}"
299+
}
300+
260301
## Update internal dependency references in a qlpack.yml file
261302
## e.g., advanced-security/javascript-sap-cap-models: "^2.3.0" -> "^2.4.0"
262303
## e.g., advanced-security/javascript-sap-cap-models: "^2.3.0" -> "^2.4.0-alpha"
@@ -327,14 +368,15 @@ update_versions() {
327368
fi
328369
done
329370

330-
## Update qlt.conf.json
371+
## Update qlt.conf.json and .codeql-version
331372
update_qlt_config "${new_version}" "${dry_run}"
373+
update_codeql_version_file "${new_version}" "${dry_run}"
332374

333375
echo ""
334376
if [[ "${dry_run}" == true ]]; then
335-
echo "Would update ${updated_count} qlpack files + qlt.conf.json. (Dry run — no files modified)"
377+
echo "Would update ${updated_count} qlpack files + qlt.conf.json + .codeql-version. (Dry run — no files modified)"
336378
else
337-
echo "Updated ${updated_count} qlpack files + qlt.conf.json to version ${new_version}."
379+
echo "Updated ${updated_count} qlpack files + qlt.conf.json + .codeql-version to version ${new_version}."
338380
echo ""
339381
echo "Next steps:"
340382
echo " 1. Run 'codeql pack upgrade' on all packs to update lock files"

0 commit comments

Comments
 (0)