Skip to content

Commit 8a5abbf

Browse files
committed
Fix release-codeql.yml workflow conditionals
1 parent d37af97 commit 8a5abbf

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

.github/workflows/release-codeql.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ jobs:
7070
- name: CodeQL - Install CodeQL pack dependencies
7171
run: server/scripts/install-packs.sh
7272

73+
- name: CodeQL - Validate version consistency
74+
run: |
75+
RELEASE_NAME="${{ steps.version.outputs.release_name }}"
76+
echo "Validating all version-bearing files match ${RELEASE_NAME}..."
77+
./server/scripts/update-release-version.sh --check "${RELEASE_NAME}"
78+
7379
- name: CodeQL - Publish CodeQL tool query packs
7480
if: inputs.publish_codeql_packs
7581
env:

.github/workflows/release-npm.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ jobs:
7171
- name: npm - Build server
7272
run: npm run build -w server
7373

74+
- name: npm - Validate version consistency
75+
run: |
76+
RELEASE_NAME="${{ steps.version.outputs.release_name }}"
77+
echo "Validating all version-bearing files match ${RELEASE_NAME}..."
78+
./server/scripts/update-release-version.sh --check "${RELEASE_NAME}"
79+
7480
- name: npm - Publish npm package
7581
working-directory: server
7682
run: |

.github/workflows/release.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
type: boolean
1414
publish_codeql_packs:
1515
default: true
16-
description: 'Publish CodeQL tool query packs to GHCR. Disable for pre-release or re-run scenarios where packs already exist.'
16+
description: 'Publish CodeQL tool query packs to GHCR. Disable for pre-release or re-run scenarios where packs already exist. Packs are always bundled as release artifacts regardless of this setting.'
1717
required: false
1818
type: boolean
1919
publish_npm:
@@ -120,14 +120,15 @@ jobs:
120120
version: ${{ needs.resolve-version.outputs.version }}
121121

122122
# ─────────────────────────────────────────────────────────────────────────────
123-
# Step 3b: Publish and bundle CodeQL packs
123+
# Step 3b: Bundle and optionally publish CodeQL packs
124124
#
125-
# Checks out the clean tag, installs CodeQL, and publishes + bundles packs.
125+
# Checks out the clean tag, installs CodeQL, and bundles packs for release.
126+
# Publishing to GHCR is controlled by the publish_codeql_packs flag; bundling
127+
# always runs so that pack artifacts are available for the GitHub Release.
126128
# Runs in parallel with npm publishing since they are independent.
127129
# ─────────────────────────────────────────────────────────────────────────────
128130
publish-codeql:
129131
name: Publish CodeQL Packs
130-
if: needs.resolve-version.outputs.publish_codeql_packs == 'true'
131132
needs: [resolve-version, ensure-tag]
132133
permissions:
133134
contents: read
@@ -142,17 +143,16 @@ jobs:
142143
#
143144
# Downloads the clean build artifact (from npm workflow) and pack bundles
144145
# (from CodeQL workflow), assembles the distribution archive, and creates the
145-
# GitHub Release. Only runs for full releases (all publish steps enabled and
146-
# create_github_release is true). Partial workflows (e.g., re-publishing only
147-
# npm or only CodeQL packs) skip this step.
146+
# GitHub Release. Requires npm publishing and create_github_release to be
147+
# enabled. CodeQL packs are always bundled as release artifacts regardless of
148+
# the publish_codeql_packs flag.
148149
# ─────────────────────────────────────────────────────────────────────────────
149150
create-release:
150151
name: Create GitHub Release
151152
if: >-
152153
always() && !failure() && !cancelled()
153154
&& needs.resolve-version.outputs.create_github_release == 'true'
154155
&& needs.resolve-version.outputs.publish_npm == 'true'
155-
&& needs.resolve-version.outputs.publish_codeql_packs == 'true'
156156
needs: [resolve-version, ensure-tag, publish-npm, publish-codeql]
157157
runs-on: ubuntu-latest
158158

@@ -232,7 +232,11 @@ jobs:
232232
echo "| Server build | ✅ Success |" >> $GITHUB_STEP_SUMMARY
233233
echo "| Version validation | ✅ All files match ${RELEASE_NAME} |" >> $GITHUB_STEP_SUMMARY
234234
echo "| npm publish | ✅ Published to npmjs.org |" >> $GITHUB_STEP_SUMMARY
235-
echo "| CodeQL pack publish | ✅ Published to GHCR |" >> $GITHUB_STEP_SUMMARY
235+
if [ "${{ needs.resolve-version.outputs.publish_codeql_packs }}" == "true" ]; then
236+
echo "| CodeQL pack publish | ✅ Published to GHCR |" >> $GITHUB_STEP_SUMMARY
237+
else
238+
echo "| CodeQL pack publish | ⏭️ Skipped (packs bundled only) |" >> $GITHUB_STEP_SUMMARY
239+
fi
236240
echo "| Distribution archive | ✅ Created |" >> $GITHUB_STEP_SUMMARY
237241
echo "| GitHub Release | ✅ Created |" >> $GITHUB_STEP_SUMMARY
238242
echo "" >> $GITHUB_STEP_SUMMARY

server/scripts/setup-packs.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ EOF
4141
while [[ $# -gt 0 ]]; do
4242
case $1 in
4343
--language)
44+
if [[ $# -lt 2 || "$2" =~ ^- ]]; then
45+
echo "Error: --language requires a value" >&2
46+
usage >&2
47+
exit 1
48+
fi
4449
LANGUAGE="$2"
4550
shift 2
4651
;;
@@ -91,9 +96,14 @@ SCRIPT_PATH="${BASH_SOURCE[0]}"
9196
if command -v realpath &> /dev/null; then
9297
SCRIPT_PATH="$(realpath "${SCRIPT_PATH}")"
9398
elif command -v readlink &> /dev/null; then
94-
# macOS readlink doesn't support -f, use a loop
99+
# macOS readlink doesn't support -f, use a loop to resolve symlinks
95100
while [ -L "${SCRIPT_PATH}" ]; do
96-
SCRIPT_PATH="$(readlink "${SCRIPT_PATH}")"
101+
LINK_TARGET="$(readlink "${SCRIPT_PATH}")"
102+
# Resolve relative targets against the symlink's directory
103+
if [[ "${LINK_TARGET}" != /* ]]; then
104+
LINK_TARGET="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)/${LINK_TARGET}"
105+
fi
106+
SCRIPT_PATH="${LINK_TARGET}"
97107
done
98108
fi
99109
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)"

server/scripts/update-release-version.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,30 @@ check_versions() {
127127
first_version="${version}"
128128
fi
129129

130+
## .codeql-version stores only the base version (X.Y.Z) even for
131+
## prerelease tags. Compare it against the base version of the expected
132+
## value or the first version to avoid false mismatches.
133+
local effective_expected effective_first
134+
if [[ "${file}" == ".codeql-version" ]]; then
135+
effective_expected="${expected_version%%-*}"
136+
effective_first="${first_version%%-*}"
137+
else
138+
effective_expected="${expected_version}"
139+
effective_first="${first_version}"
140+
fi
141+
130142
if [[ -n "${expected_version}" ]]; then
131-
if [[ "${version}" == "${expected_version}" ]]; then
143+
if [[ "${version}" == "${effective_expected}" ]]; then
132144
echo "${file}: ${version}"
133145
else
134-
echo "${file}: ${version} (expected ${expected_version})"
146+
echo "${file}: ${version} (expected ${effective_expected})"
135147
all_consistent=false
136148
fi
137149
else
138-
if [[ "${version}" == "${first_version}" ]]; then
150+
if [[ "${version}" == "${effective_first}" ]]; then
139151
echo "${file}: ${version}"
140152
else
141-
echo "${file}: ${version} (differs from ${first_version})"
153+
echo "${file}: ${version} (differs from ${effective_first})"
142154
all_consistent=false
143155
fi
144156
fi

0 commit comments

Comments
 (0)