#!/usr/bin/env bash set -euo pipefail # ----- Resolve and enter the repository root ----- REPO_ROOT="$(git rev-parse --show-toplevel)" cd "$REPO_ROOT" # ----- Set the output file, with a default project path ----- OUTPUT_FILE="${1:-./data/gen/build_info.typ}" # ----- Retrieve the current Git commit identifiers ----- build_commit="$(git rev-parse HEAD)" build_commit_short="$(git rev-parse --short HEAD)" # ----- Retrieve the latest reachable Git tag ----- build_version="$(git describe --tags --abbrev=0 2>/dev/null || true)" build_version="${build_version:-}" # ----- Check whether the main Typst document builds successfully ----- if typst query main.typ '' >/dev/null 2>&1; then build_status="true" else build_status="false" fi # ----- Generate the Typst build metadata file ----- cat > "$OUTPUT_FILE" <