-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_version_drift.sh
More file actions
executable file
·56 lines (49 loc) · 1.94 KB
/
Copy pathcheck_version_drift.sh
File metadata and controls
executable file
·56 lines (49 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# check_version_drift.sh — assert every *software* version string matches the
# canonical source of truth: main.zig's VERSION constant.
#
# Scope: the shipped-software version (the library, the CLI, the panel
# descriptors). The `[metadata] version` fields in .machine_readable/**/*.a2ml
# are the versions of those metadata documents themselves, not the software,
# and are deliberately NOT checked here.
#
# Run from anywhere: scripts/check_version_drift.sh
set -euo pipefail
cd "$(dirname "$0")/.."
canonical=$(grep -oE 'VERSION: \[:0\]const u8 = "[0-9]+\.[0-9]+\.[0-9]+"' \
src/interface/ffi/src/main.zig | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
if [[ -z "${canonical:-}" ]]; then
echo "ERROR: could not read canonical VERSION from main.zig" >&2
exit 2
fi
echo "canonical (main.zig VERSION) = $canonical"
fail=0
check() {
local file="$1" ver="$2"
if [[ "$ver" != "$canonical" ]]; then
echo "DRIFT: $file = '$ver' (expected '$canonical')"
fail=1
fi
}
# main.zig BUILD_INFO
check "main.zig BUILD_INFO" \
"$(grep -oE 'libgsa [0-9]+\.[0-9]+\.[0-9]+' src/interface/ffi/src/main.zig | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
# build.zig — both .version structs
while read -r v; do check "build.zig .version" "$v"; done < <(
grep -oE '\.major = [0-9]+, \.minor = [0-9]+, \.patch = [0-9]+' src/interface/ffi/build.zig \
| grep -oE '[0-9]+' | paste -sd' ' - | awk '{for(i=1;i<=NF;i+=3) print $i"."$(i+1)"."$(i+2)}')
# run.js
check "run.js" \
"$(grep -oE 'version: "[0-9]+\.[0-9]+\.[0-9]+"' run.js | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
# panels
for f in panels/manifest.json panels/*/panel.json; do
check "$f" "$(grep -oE '"version": "[0-9]+\.[0-9]+\.[0-9]+"' "$f" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
done
if [[ $fail -eq 0 ]]; then
echo "OK: all software versions == $canonical"
else
echo "Version drift detected. Update the offending files or main.zig's VERSION." >&2
exit 1
fi