jevhooks.git / tools / check-versions.sh
1#!/usr/bin/env bash
2# Fail if a version written outside mise.toml differs from the one in it. mise.toml is the one place
3# versions live; these are the few other files that cannot read it and so repeat one.
4#
5#     tools/check-versions.sh
6#
7# Needs only POSIX tools: it reads mise.toml's `key = "value"` lines, not a TOML parser.
8set -euo pipefail
9cd "$(dirname "$0")/.."
10fail=0
11bad() { echo "check-versions: $*" >&2; fail=1; }
12tool() { grep -m1 -E "^\"?$1\"? *= *\"" mise.toml | sed -E 's/^[^=]*= *"([^"]*)".*/\1/'; }
13
14hk="$(tool hk)"
15[ -n "$hk" ] || bad "mise.toml has no hk"
16grep -q "hk@$hk#" hk.pkl || bad "hk.pkl does not reference hk $hk (the release mise.toml installs)"
17
18# Nothing may pin a toolchain in the flake: it only wraps mise.
19if grep -nE 'fenix|rust-bin|rustc|binaryen' flake.nix >&2; then
20  bad "flake.nix names a toolchain; the toolchain is mise.toml's"
21fi
22[ "$fail" = 0 ] && echo "check-versions: ok"
23exit "$fail"