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; } 12# first quoted value on the first line of $2 that starts with $1 (the key, as written) 13val() { grep -m1 -E "^$1 *=" "$2" | sed -E 's/^[^=]*= *"([^"]*)".*/\1/'; } 14tool() { grep -m1 -E "^\"?$1\"? *= *\"" mise.toml | sed -E 's/^[^=]*= *"([^"]*)".*/\1/'; } 15 16wb="$(tool 'cargo:wasm-bindgen-cli')" 17[ -n "$wb" ] || bad "mise.toml has no cargo:wasm-bindgen-cli" 18for f in web/Cargo.toml backend/worker/Cargo.toml; do 19 pin="$(grep -m1 -E '^wasm-bindgen *= *"=' "$f" | sed -E 's/.*"=([^"]*)".*/\1/')" 20 [ "$pin" = "$wb" ] || bad "$f pins wasm-bindgen $pin, mise.toml installs the CLI $wb" 21done 22 23platform="$(val android_platform mise.toml)"; platform="${platform%.0}"; tools_v="$(val android_build_tools mise.toml)" 24g=android/app/build.gradle.kts 25[ "$(sed -nE 's/^ *compileSdk = ([0-9]+).*/\1/p' $g)" = "$platform" ] || bad "$g compileSdk differs from android_platform ($platform)" 26[ "$(sed -nE 's/^ *buildToolsVersion = "([^"]*)".*/\1/p' $g)" = "$tools_v" ] || bad "$g buildToolsVersion differs from android_build_tools ($tools_v)" 27 28jdk="$(tool java | sed -E 's/^[a-z]+-([0-9]+).*/\1/')" 29[ "$(sed -nE 's/^ *jvmToolchain\(([0-9]+)\).*/\1/p' $g)" = "$jdk" ] || bad "$g jvmToolchain differs from the JDK in mise.toml ($jdk)" 30 31hk="$(tool hk)" 32grep -q "hk@$hk#" hk.pkl || bad "hk.pkl does not reference hk $hk (the release mise.toml installs)" 33 34# Nothing may pin a tool version in the flake: it only wraps mise. 35if grep -nE 'platformVersions|buildToolsVersions|ndkVersion|gradle_[0-9]|jdk[0-9]+' flake.nix >&2; then 36 bad "flake.nix pins a toolchain version; the toolchain is mise.toml's" 37fi 38[ "$fail" = 0 ] && echo "check-versions: ok" 39exit "$fail"