blob: ec7c62af0b86299d3d92d860aef94401d4e0bef3 [file] [log] [blame]
Josh Bleecher Snyder6ae637a2025-07-09 12:41:56 -07001#!/bin/bash
2set -e
3
Josh Bleecher Snyder39eb24f2025-07-10 01:46:33 +00004# Use a content-based hash of the webui dir to avoid unnecessary rebuilds.
5OUTPUT_DIR="embedded/webui-dist"
6# go:embed ignores files that start with a '.'
7HASH_FILE="$OUTPUT_DIR/.input_hash"
8
9calculate_input_hash() {
10 local tmp=$(mktemp)
11 (
12 export GIT_INDEX_FILE="$tmp"
13 git read-tree --empty
14 git add webui/
15 git write-tree
16 )
17 rm -f "$tmp"
18}
19
20CURRENT_HASH=$(calculate_input_hash)
21
22if [ -f "$HASH_FILE" ] && [ -d "$OUTPUT_DIR" ]; then
23 STORED_HASH=$(cat "$HASH_FILE")
24 if [ "$CURRENT_HASH" = "$STORED_HASH" ]; then
25 # No changes, skip rebuild
26 exit 0
27 fi
28fi
29
30rm -rf "$OUTPUT_DIR"
31unset GOOS GOARCH && go run ./cmd/genwebui -- "$OUTPUT_DIR"
32echo "$CURRENT_HASH" >"$HASH_FILE"