1515 #
1616 # Compares the current CodeQL CLI version in qlt.conf.json against the latest
1717 # release from github/codeql-cli-binaries. If a newer version is available,
18- # downstream jobs orchestrate a full release using the same child workflows
19- # as release.yml, guarded by environment approval gates.
18+ # downstream jobs orchestrate the update and PR creation.
2019 # ─────────────────────────────────────────────────────────────────────────────
2120 detect-update :
2221 name : Detect CodeQL CLI Update
3837 GH_TOKEN : ${{ github.token }}
3938 run : |
4039 echo "Checking latest CodeQL CLI version..."
40+
41+ # Read current version from qlt.conf.json
4142 current_version=$(jq -r .CodeQLCLI qlt.conf.json)
43+
44+ # Get latest release from codeql-cli-binaries
4245 latest_tag=$(gh release list --repo github/codeql-cli-binaries --json 'tagName,isLatest' --jq '.[] | select(.isLatest == true) | .tagName')
46+
47+ # Validate that we found a latest release
48+ if [ -z "${latest_tag}" ]; then
49+ echo "❌ Error: Could not determine latest CodeQL CLI version from github/codeql-cli-binaries" >&2
50+ echo "No release marked as 'latest' was found. This may indicate an API issue or repository change." >&2
51+ echo "update_needed=false" >> $GITHUB_OUTPUT
52+ exit 1
53+ fi
54+
4355 latest_clean="${latest_tag#v}"
4456
4557 echo "Current CodeQL CLI version: ${current_version}"
@@ -63,91 +75,128 @@ jobs:
6375 if [ "${{ steps.check-version.outputs.update_needed }}" == "true" ]; then
6476 echo "✅ Update available: ${{ steps.check-version.outputs.current_version }} → ${{ steps.check-version.outputs.latest_version }}" >> $GITHUB_STEP_SUMMARY
6577 echo "" >> $GITHUB_STEP_SUMMARY
66- echo "Initiating release pipeline for \`v ${{ steps.check-version.outputs.latest_version }}\`..." >> $GITHUB_STEP_SUMMARY
78+ echo "Initiating update pipeline for \`${{ steps.check-version.outputs.version }}\`..." >> $GITHUB_STEP_SUMMARY
6779 else
68- echo "ℹ️ CodeQL CLI is already up-to-date. No release needed." >> $GITHUB_STEP_SUMMARY
80+ echo "ℹ️ CodeQL CLI is already up-to-date. No changes needed." >> $GITHUB_STEP_SUMMARY
6981 fi
7082
7183 # ─────────────────────────────────────────────────────────────────────────────
72- # Step 2: Create release tag
84+ # Step 2: Update version, test, and create PR
7385 #
74- # Calls the same release-tag workflow used by release .yml. This ensures the
75- # version update, CodeQL installation, pack lock upgrade, unit tests, and tag
76- # creation all follow the same validated process .
86+ # Updates all version-bearing files (qlt.conf.json, qlpack .yml files),
87+ # installs CodeQL, upgrades pack lock files, compiles CDS files, runs unit
88+ # tests, and creates a pull request with the changes .
7789 #
78- # The release-tag environment approval gate provides human-in- the-loop review
79- # before any changes are committed .
90+ # This does NOT trigger the release pipeline. Merging the PR and creating a
91+ # release tag is a separate, human-initiated step via release.yml .
8092 # ─────────────────────────────────────────────────────────────────────────────
81- ensure-tag :
82- name : Ensure Release Tag
93+ create-pr :
94+ name : Create Update Pull Request
8395 needs : detect-update
8496 if : needs.detect-update.outputs.update_needed == 'true'
85- permissions :
86- contents : write
87- uses : ./.github/workflows/release-tag.yml
88- with :
89- version : ${{ needs.detect-update.outputs.version }}
90-
91- # ─────────────────────────────────────────────────────────────────────────────
92- # Step 3: Publish and bundle CodeQL packs
93- #
94- # Calls the same release-codeql workflow used by release.yml. Publishes packs
95- # to GHCR and bundles them as artifacts for the GitHub Release.
96- # ─────────────────────────────────────────────────────────────────────────────
97- publish-codeql :
98- name : Publish CodeQL Packs
99- needs : [detect-update, ensure-tag]
100- if : needs.detect-update.outputs.update_needed == 'true'
101- permissions :
102- contents : read
103- packages : write
104- uses : ./.github/workflows/release-codeql.yml
105- with :
106- publish_codeql_packs : true
107- version : ${{ needs.detect-update.outputs.version }}
108-
109- # ─────────────────────────────────────────────────────────────────────────────
110- # Step 4: Create GitHub Release
111- #
112- # Downloads the CodeQL pack bundles and creates the GitHub Release with
113- # auto-generated release notes and attached pack artifacts.
114- # ─────────────────────────────────────────────────────────────────────────────
115- create-release :
116- name : Create GitHub Release
117- needs : [detect-update, ensure-tag, publish-codeql]
118- if : >-
119- always() && !failure() && !cancelled()
120- && needs.detect-update.outputs.update_needed == 'true'
12197 runs-on : ubuntu-latest
12298
12399 permissions :
124100 contents : write
101+ pull-requests : write
125102
126103 steps :
127- - name : Release - Download CodeQL pack artifacts
128- uses : actions/download-artifact@v7
129- with :
130- name : codeql-pack-bundles-${{ needs.detect-update.outputs.version }}
131- path : dist-packs
104+ - name : Update - Checkout repository
105+ uses : actions/checkout@v6
132106
133- - name : Release - Create GitHub Release
134- uses : softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
107+ - name : Update - Update version in all files
108+ run : |
109+ LATEST="${{ needs.detect-update.outputs.latest_version }}"
110+ echo "Updating all version-bearing files to ${LATEST}..."
111+ chmod +x ./scripts/update-release-version.sh
112+ ./scripts/update-release-version.sh "${LATEST}"
113+
114+ - name : Update - Install CodeQL via GitHub CLI
115+ env :
116+ GH_TOKEN : ${{ github.token }}
117+ shell : bash
118+ run : |
119+ CODEQL_VERSION="${{ needs.detect-update.outputs.latest_version }}"
120+ echo "Installing CodeQL CLI ${CODEQL_VERSION} via gh-codeql..."
121+ gh extension install github/gh-codeql
122+ gh codeql set-version "${CODEQL_VERSION}"
123+ STUB_DIR="$HOME/.local/bin"
124+ mkdir -p "${STUB_DIR}"
125+ gh codeql install-stub "${STUB_DIR}/"
126+ echo "${STUB_DIR}" >> "$GITHUB_PATH"
127+ export PATH="${STUB_DIR}:${PATH}"
128+ echo "CodeQL version: $(codeql version --format=terse)"
129+
130+ - name : Update - Upgrade CodeQL pack lock files
131+ shell : bash
132+ run : |
133+ echo "Upgrading CodeQL pack lock files..."
134+ find . -name "qlpack.yml" -type f | sort | while read -r qlpack_file; do
135+ pack_dir=$(dirname "$qlpack_file")
136+ echo "Upgrading pack in directory: $pack_dir"
137+ cd "$pack_dir"
138+ codeql pack upgrade
139+ cd - > /dev/null
140+ done
141+ echo "Finished upgrading all CodeQL pack lock files"
142+
143+ - name : Update - Setup Node.js for CDS compilation
144+ uses : actions/setup-node@v6
135145 with :
136- files : |
137- dist-packs/*.tar.gz
138- generate_release_notes : true
139- tag_name : ${{ needs.detect-update.outputs.version }}
146+ node-version : ' 20'
147+ cache : ' npm'
148+ cache-dependency-path : ' extractors/cds/tools/package-lock.json'
149+
150+ - name : Update - Compile CAP CDS files
151+ run : |
152+ chmod +x ./extractors/cds/tools/workflow/cds-compilation-for-actions.sh
153+ ./extractors/cds/tools/workflow/cds-compilation-for-actions.sh
140154
141- - name : Release - Summary
155+ - name : Update - Run CodeQL unit tests
156+ env :
157+ LGTM_INDEX_XML_MODE : all
158+ LGTM_INDEX_FILETYPES : " .json:JSON\n .cds:JSON"
159+ shell : bash
160+ run : |
161+ echo "Running CodeQL unit tests to validate update..."
162+ codeql test run \
163+ --threads=0 \
164+ --strict-test-discovery \
165+ --additional-packs="${GITHUB_WORKSPACE}" \
166+ -- javascript/
167+
168+ - name : Update - Create Pull Request
169+ uses : peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
170+ with :
171+ title : ' Upgrade CodeQL CLI dependency to ${{ needs.detect-update.outputs.version }}'
172+ body : |
173+ This PR upgrades the CodeQL CLI version to ${{ needs.detect-update.outputs.version }}.
174+
175+ **Changes made:**
176+ - Updated `qlt.conf.json` (CodeQLCLI, CodeQLStandardLibrary, CodeQLCLIBundle) to `${{ needs.detect-update.outputs.latest_version }}`
177+ - Updated all version-bearing qlpack.yml files to `${{ needs.detect-update.outputs.latest_version }}`
178+ - Upgraded CodeQL pack lock files
179+ - Compiled CAP CDS files
180+ - CodeQL unit tests passed ✅
181+
182+ **To complete the release**, merge this PR and then trigger the release workflow
183+ via `workflow_dispatch` on `release.yml` with version `${{ needs.detect-update.outputs.version }}`.
184+ commit-message : ' Upgrade CodeQL CLI dependency to ${{ needs.detect-update.outputs.version }}'
185+ delete-branch : true
186+ branch : ' codeql/upgrade-to-${{ needs.detect-update.outputs.version }}'
187+
188+ - name : Update - Summary
142189 run : |
143190 VERSION="${{ needs.detect-update.outputs.version }}"
144- RELEASE_NAME="${{ needs.detect-update.outputs.latest_version }}"
145- echo "## Automated Release Summary" >> $GITHUB_STEP_SUMMARY
191+ CURRENT="${{ needs.detect-update.outputs.current_version }}"
192+ LATEST="${{ needs.detect-update.outputs.latest_version }}"
193+ echo "## CodeQL CLI Update Summary" >> $GITHUB_STEP_SUMMARY
194+ echo "" >> $GITHUB_STEP_SUMMARY
195+ echo "Triggered by CodeQL CLI update: ${CURRENT} → ${LATEST}" >> $GITHUB_STEP_SUMMARY
146196 echo "" >> $GITHUB_STEP_SUMMARY
147- echo "Triggered by CodeQL CLI update: ${{ needs.detect-update.outputs.current_version }} → ${RELEASE_NAME}" >> $GITHUB_STEP_SUMMARY
197+ echo "| Property | Old Value | New Value |" >> $GITHUB_STEP_SUMMARY
198+ echo "| -------- | --------- | --------- |" >> $GITHUB_STEP_SUMMARY
199+ echo "| qlt.conf.json CodeQLCLI | ${CURRENT} | ${LATEST} |" >> $GITHUB_STEP_SUMMARY
200+ echo "| qlpack.yml versions | ${CURRENT} | ${LATEST} |" >> $GITHUB_STEP_SUMMARY
148201 echo "" >> $GITHUB_STEP_SUMMARY
149- echo "| Step | Status |" >> $GITHUB_STEP_SUMMARY
150- echo "| ---- | ------ |" >> $GITHUB_STEP_SUMMARY
151- echo "| Tag | ✅ ${VERSION} |" >> $GITHUB_STEP_SUMMARY
152- echo "| CodeQL pack publish | ✅ Published to GHCR |" >> $GITHUB_STEP_SUMMARY
153- echo "| GitHub Release | ✅ Created |" >> $GITHUB_STEP_SUMMARY
202+ echo "A pull request has been created with these changes." >> $GITHUB_STEP_SUMMARY
0 commit comments