Skip to content

Commit a49e01a

Browse files
felickzCopilot
andauthored
feat(update-codeql-version): add optional release_bump input to publish in the same PR (#167)
* feat(update-codeql-version): add optional release_bump input to fold a release into the same PR Adds an optional 'release_bump' string input (patch/minor/major, default empty) to update-codeql-version.yml. When set, the workflow runs the same 42ByteLabs/patch-release-me step update-release.yml uses, in the same run, folding a full release bump (every pack's version:, configs/*.yml refs, and cross-pack -libs pins) into the CLI/library dependency-refresh PR. Since publish.yml's auto-trigger fires on any push to main that changes .release.yml, merging this combined PR is then enough by itself to kick off the real batch publish - no separate update-release.yml run needed afterward for same-series patch bumps expected to be safe. Also: - Adds /codeql_home/ to .release.yml's excludes, since the new release_bump code path runs patch-release-me in a job where codeql_home/ already exists (from the earlier Setup CodeQL step) - a scenario update-release.yml, run standalone, never previously encountered. - Rewrites the PR title/body generation to branch on whether release_bump was set, so the PR clearly documents whether merging it will publish. - Documents the new input and combined-PR flow in CONTRIBUTING.md's 'Updating the pinned CodeQL CLI/library version' section. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * fix(update-codeql-version): write pr-body.md outside the git working tree Write the generated PR body to \ instead of the repo root, so peter-evans/create-pull-request doesn't pick it up as an untracked file and accidentally commit it into the PR it opens. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d275b8d commit a49e01a

3 files changed

Lines changed: 138 additions & 40 deletions

File tree

‎.github/workflows/update-codeql-version.yml‎

Lines changed: 105 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,35 @@ name: Update CodeQL CLI Version
33
# Bumps the pinned CodeQL CLI/library version (.codeqlversion) and refreshes every
44
# pack's codeql-pack.lock.yml against it, then opens a PR with the result.
55
#
6-
# This does NOT publish anything by itself and does NOT bump any pack's `version:`
6+
# By default this does NOT publish anything and does NOT bump any pack's `version:`
77
# field - it only prepares the dependency-refresh half of the process documented in
88
# CONTRIBUTING.md's "Updating the pinned CodeQL CLI/library version" section. A human
99
# (or a delegated Copilot coding agent) still needs to fix any compilation/test
1010
# breakage the new CLI/library versions introduce before merging, and the existing
1111
# "CodeQL Update Release" workflow (update-release.yml) is still what bumps every
1212
# pack's version and triggers the real batch publish once this PR is merged.
13+
#
14+
# Optionally, set `release_bump` (patch/minor/major) to fold that release bump into
15+
# THIS SAME PR - it runs the same `patch-release-me` step update-release.yml uses,
16+
# which bumps `.release.yml`'s repo-wide version and propagates it to every pack's
17+
# own `version:` field, `configs/*.yml` references, and cross-pack `-libs` pins in
18+
# one pass. Since publish.yml's auto-trigger fires on any push to `main` that changes
19+
# `.release.yml`, merging this one combined PR is then enough to kick off the real
20+
# batch publish immediately - no separate "CodeQL Update Release" run needed
21+
# afterward. Leave `release_bump` empty (the default) to only refresh dependencies,
22+
# e.g. when you expect CI breakage that needs fixing before it's safe to publish.
1323
on:
1424
workflow_dispatch:
1525
inputs:
1626
codeql_version:
1727
description: "New CodeQL CLI version to pin, e.g. 2.22.0 (a leading 'v' is fine too)"
1828
required: true
1929
type: string
30+
release_bump:
31+
description: "Optional: patch/minor/major - also bump the repo release version and every pack's version in this same PR to trigger a real publish on merge. Leave empty to only refresh dependencies (default)."
32+
required: false
33+
type: string
34+
default: ""
2035

2136
jobs:
2237
update-codeql-version:
@@ -41,6 +56,17 @@ jobs:
4156
fi
4257
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4358
59+
- name: Validate release_bump input
60+
id: release_bump
61+
run: |
62+
set -euo pipefail
63+
BUMP="${{ inputs.release_bump }}"
64+
if [[ -n "$BUMP" && ! "$BUMP" =~ ^(patch|minor|major)$ ]]; then
65+
echo "::error::release_bump must be 'patch', 'minor', 'major', or empty - got: ${{ inputs.release_bump }}" >&2
66+
exit 1
67+
fi
68+
echo "bump=$BUMP" >> "$GITHUB_OUTPUT"
69+
4470
- name: Update .codeqlversion
4571
run: |
4672
echo "${{ steps.version.outputs.version }}" > .codeqlversion
@@ -81,6 +107,21 @@ jobs:
81107
echo "::endgroup::"
82108
done
83109
110+
- name: Bump release version (optional)
111+
if: steps.release_bump.outputs.bump != ''
112+
uses: 42ByteLabs/patch-release-me@04ea0a696abfc3cfbdfadb279bd9c9dd0b1652a2 # 0.6.6
113+
with:
114+
mode: ${{ steps.release_bump.outputs.bump }}
115+
116+
- name: Determine new release version (if bumped)
117+
id: release_version
118+
if: steps.release_bump.outputs.bump != ''
119+
run: |
120+
set -euo pipefail
121+
NEW_VERSION="$(grep -E '^version:' .release.yml | head -1 | sed -E 's/^version:[[:space:]]*"?([^"[:space:]]+)"?/\1/')"
122+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
123+
echo "Release version bumped to ${NEW_VERSION}"
124+
84125
- name: Summarize changed files
85126
run: |
86127
{
@@ -96,39 +137,73 @@ jobs:
96137
app-id: ${{ secrets.SECLABS_APP_ID }}
97138
private-key: ${{ secrets.SECLABS_APP_KEY }}
98139

140+
- name: Build PR title and body
141+
id: pr_meta
142+
run: |
143+
set -euo pipefail
144+
if [[ -n "${{ steps.release_bump.outputs.bump }}" ]]; then
145+
TITLE="chore: bump pinned CodeQL CLI to v${{ steps.version.outputs.version }} and release v${{ steps.release_version.outputs.version }}"
146+
else
147+
TITLE="chore: bump pinned CodeQL CLI to v${{ steps.version.outputs.version }}"
148+
fi
149+
echo "title=$TITLE" >> "$GITHUB_OUTPUT"
150+
151+
{
152+
echo 'Automated CLI version bump, requested via the "Update CodeQL CLI Version"'
153+
echo "workflow (\`workflow_dispatch\`, \`codeql_version: ${{ steps.version.outputs.version }}\`, \`release_bump: ${{ steps.release_bump.outputs.bump || '(none)' }}\`)."
154+
echo
155+
echo "This PR:"
156+
echo '- Updates `.codeqlversion` to `'"${{ steps.version.outputs.version }}"'`.'
157+
echo '- Pins every `codeql/<lang>-all` / `codeql/<lang>-queries` dependency across all'
158+
echo ' `qlpack.yml` files to the exact version shipped in the official CodeQL Bundle'
159+
echo ' for this CLI release (see `.github/scripts/pin-codeql-library-versions.sh`) -'
160+
echo ' this keeps `codeql pack upgrade` from jumping those libraries to'
161+
echo ' registry-latest instead of the version this CLI actually ships/tests against.'
162+
echo '- Runs `codeql pack upgrade <dir>` for every pack directory to refresh its'
163+
echo ' `codeql-pack.lock.yml` against the new CLI and pinned library versions.'
164+
echo
165+
if [[ -n "${{ steps.release_bump.outputs.bump }}" ]]; then
166+
echo "- Also bumps the repo release version (\`${{ steps.release_bump.outputs.bump }}\`, via the same"
167+
echo ' `patch-release-me` step `update-release.yml` uses) to `'"${{ steps.release_version.outputs.version }}"'`,'
168+
echo " propagating it to every pack's own \`version:\` field, \`configs/*.yml\`"
169+
echo ' references, and cross-pack `-libs` pins.'
170+
echo
171+
echo '**Merging this PR triggers the real batch publish** - `publish.yml`'"'"'s'
172+
echo 'auto-trigger fires on any push to `main` that changes `.release.yml`, which this'
173+
echo 'PR does. No separate "CodeQL Update Release" run is needed.'
174+
echo
175+
echo 'Remaining steps (see CONTRIBUTING.md'"'"'s "Updating the pinned CodeQL CLI/library'
176+
echo 'version" section):'
177+
echo
178+
echo '- [ ] Check CI on this PR - fix any compilation/test errors caused by upstream'
179+
echo ' API changes. This is usually the hardest part; consider delegating it to a'
180+
echo ' Copilot coding agent session pointed at this PR/branch.'
181+
echo '- [ ] Update the "Supported CodeQL versions" table in CONTRIBUTING.md.'
182+
echo '- [ ] Review and merge - this alone will trigger the real batch publish.'
183+
else
184+
echo '**This PR does not publish anything by itself** - no pack `version:` field is'
185+
echo "bumped here, so \`publish.yml\`'s version-diff trigger won't fire for it yet."
186+
echo 'Remaining steps (see CONTRIBUTING.md'"'"'s "Updating the pinned CodeQL CLI/library'
187+
echo 'version" section):'
188+
echo
189+
echo '- [ ] Check CI on this PR - fix any compilation/test errors caused by upstream'
190+
echo ' API changes. This is usually the hardest part; consider delegating it to a'
191+
echo ' Copilot coding agent session pointed at this PR/branch.'
192+
echo '- [ ] Update the "Supported CodeQL versions" table in CONTRIBUTING.md.'
193+
echo '- [ ] Review and merge.'
194+
echo '- [ ] Once merged, run the "CodeQL Update Release" workflow'
195+
echo ' (`update-release.yml`) to bump every pack'"'"'s `version:` in lockstep via'
196+
echo ' `.release.yml` and trigger the real batch publish.'
197+
fi
198+
} > "${{ runner.temp }}/pr-body.md"
199+
99200
- name: Create Pull Request
100201
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
101202
with:
102203
token: ${{ steps.get_workflow_token.outputs.token }}
103-
title: "chore: bump pinned CodeQL CLI to v${{ steps.version.outputs.version }}"
104-
commit-message: "chore: bump pinned CodeQL CLI to v${{ steps.version.outputs.version }}"
105-
body: |
106-
Automated CLI version bump, requested via the "Update CodeQL CLI Version"
107-
workflow (`workflow_dispatch`, `codeql_version: ${{ steps.version.outputs.version }}`).
108-
109-
This PR:
110-
- Updates `.codeqlversion` to `${{ steps.version.outputs.version }}`.
111-
- Pins every `codeql/<lang>-all` / `codeql/<lang>-queries` dependency across all
112-
`qlpack.yml` files to the exact version shipped in the official CodeQL Bundle
113-
for this CLI release (see `.github/scripts/pin-codeql-library-versions.sh`) -
114-
this keeps `codeql pack upgrade` from jumping those libraries to
115-
registry-latest instead of the version this CLI actually ships/tests against.
116-
- Runs `codeql pack upgrade <dir>` for every pack directory to refresh its
117-
`codeql-pack.lock.yml` against the new CLI and pinned library versions.
118-
119-
**This PR does not publish anything by itself** - no pack `version:` field is
120-
bumped here, so `publish.yml`'s version-diff trigger won't fire for it yet.
121-
Remaining steps (see CONTRIBUTING.md's "Updating the pinned CodeQL CLI/library
122-
version" section):
123-
124-
- [ ] Check CI on this PR - fix any compilation/test errors caused by upstream
125-
API changes. This is usually the hardest part; consider delegating it to a
126-
Copilot coding agent session pointed at this PR/branch.
127-
- [ ] Update the "Supported CodeQL versions" table in CONTRIBUTING.md.
128-
- [ ] Review and merge.
129-
- [ ] Once merged, run the "CodeQL Update Release" workflow
130-
(`update-release.yml`) to bump every pack's `version:` in lockstep via
131-
`.release.yml` and trigger the real batch publish.
204+
title: ${{ steps.pr_meta.outputs.title }}
205+
commit-message: ${{ steps.pr_meta.outputs.title }}
206+
body-path: "${{ runner.temp }}/pr-body.md"
132207
branch: "chore/update-codeql-cli-${{ steps.version.outputs.version }}"
133208
labels: "version"
134209
delete-branch: true

‎.release.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ecosystem: CodeQL
66
excludes:
77
- "/.codeql/"
88
- "/codeql/"
9+
- "/codeql_home/" # only present when run alongside update-codeql-version.yml, which downloads the CLI here
910

1011
locations:
1112
- name: "CodeQL Pack Versions"

‎CONTRIBUTING.md‎

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,38 @@ coding agent) in the loop for the hard part — fixing whatever the new CLI brea
219219
of [#118][pr-118]'s original proposal, extended to also own the `.codeqlversion` bump and the
220220
exact-version pinning (not just a bare `codeql pack upgrade` loop) and to use a token that triggers
221221
CI.
222-
3. **Fix breakage and finish the checklist** — this PR does **not** publish anything by itself (no
223-
pack `version:` field is touched), so there's no rush, but it still needs:
224-
- [ ] Fix any compilation/test errors CI surfaces from upstream API changes (usually the
225-
hardest part, see [#124][pr-124] for an example of what this can involve). Consider
226-
delegating this step to a Copilot coding agent session pointed at the PR/branch.
227-
- [ ] Update the "Supported CodeQL versions" table above.
228-
- [ ] Review and merge.
229-
- [ ] Once merged, run [`update-release.yml`][update-release-workflow] as described in
230-
[Cutting a release](#cutting-a-release) below to bump every pack's `version:` in
231-
lockstep and trigger the real batch publish.
222+
223+
By default this PR only refreshes dependencies and does not publish anything — that's the safest
224+
choice when you expect CI breakage that needs fixing first (the normal case for a minor/major CLI
225+
bump). If you're confident the bump is safe to publish as soon as CI is green (e.g. a same-series
226+
CLI patch release with no expected breaking changes), you can also set the optional `release_bump`
227+
input (`patch`/`minor`/`major`) on the same `workflow_dispatch` run. When set, this workflow runs
228+
the same [`42ByteLabs/patch-release-me`][patch-release-me] step [`update-release.yml`][update-release-workflow]
229+
uses, in this same run, folding a full [release bump](#cutting-a-release) — and everything that
230+
comes with it (every pack's `version:` field, `configs/*.yml` references, and cross-pack `-libs`
231+
pins) — into this one PR. Since [`publish.yml`][publish-workflow]'s auto-trigger fires on any push
232+
to `main` that changes `.release.yml`, merging this combined PR is then enough by itself to kick
233+
off the real batch publish — no separate `update-release.yml` run needed afterward. Leave
234+
`release_bump` empty (the default) otherwise.
235+
3. **Fix breakage and finish the checklist** — the PR's own description tells you which checklist
236+
applies, depending on whether you set `release_bump`:
237+
- **Without `release_bump` (default)** — this PR does **not** publish anything by itself (no pack
238+
`version:` field is touched), so there's no rush, but it still needs:
239+
- [ ] Fix any compilation/test errors CI surfaces from upstream API changes (usually the
240+
hardest part, see [#124][pr-124] for an example of what this can involve). Consider
241+
delegating this step to a Copilot coding agent session pointed at the PR/branch.
242+
- [ ] Update the "Supported CodeQL versions" table above.
243+
- [ ] Review and merge.
244+
- [ ] Once merged, run [`update-release.yml`][update-release-workflow] as described in
245+
[Cutting a release](#cutting-a-release) below to bump every pack's `version:` in
246+
lockstep and trigger the real batch publish.
247+
- **With `release_bump` set** — merging this PR *is* the release; there's no separate follow-up
248+
step:
249+
- [ ] Fix any compilation/test errors CI surfaces from upstream API changes, same as above.
250+
- [ ] Update the "Supported CodeQL versions" table above.
251+
- [ ] Review and merge — this alone triggers the real batch publish and the same
252+
`summary` job / GitHub Release upsert described in
253+
[Cutting a release](#cutting-a-release) below.
232254

233255
> [!NOTE]
234256
> <a id="ql-hotspots"></a>**Why `ql/hotspots` is excluded from the `codeql pack upgrade` loop:**

0 commit comments

Comments
 (0)