34 lines
806 B
Bash
Executable File
34 lines
806 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Run this script from anywhere inside the Git repository.
|
|
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$REPO_ROOT"
|
|
|
|
OUTPUT_FILE="${1:-./data/gen/build_info.typ}"
|
|
|
|
build_commit="$(git rev-parse HEAD)"
|
|
|
|
# Latest tag reachable from the current branch/commit.
|
|
build_version="$(git describe --tags --abbrev=0 2>/dev/null || true)"
|
|
build_version="${build_version:-}"
|
|
|
|
# typst query exits successfully when the query succeeds; use its
|
|
# result as the boolean value.
|
|
if typst query main.typ '<a>' >/dev/null 2>&1; then
|
|
build_status="true"
|
|
else
|
|
build_status="false"
|
|
fi
|
|
|
|
cat > "$OUTPUT_FILE" <<EOF
|
|
#let build_info = (
|
|
build_commit : "$build_commit",
|
|
build_version : "$build_version",
|
|
build_status : $build_status,
|
|
)
|
|
EOF
|
|
|
|
echo "Generated $OUTPUT_FILE"
|
|
|