| Euan Kemp | aabca2e | 2025-07-21 05:44:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 2 | set -e |
| 3 | |
| Josh Bleecher Snyder | 39eb24f | 2025-07-10 01:46:33 +0000 | [diff] [blame] | 4 | # Use a content-based hash of the webui dir to avoid unnecessary rebuilds. |
| 5 | OUTPUT_DIR="embedded/webui-dist" |
| 6 | # go:embed ignores files that start with a '.' |
| 7 | HASH_FILE="$OUTPUT_DIR/.input_hash" |
| 8 | |
| 9 | calculate_input_hash() { |
| Josh Bleecher Snyder | e3e886b | 2025-07-17 15:31:16 -0700 | [diff] [blame] | 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" |
| Josh Bleecher Snyder | 39eb24f | 2025-07-10 01:46:33 +0000 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | CURRENT_HASH=$(calculate_input_hash) |
| 21 | |
| 22 | if [ -f "$HASH_FILE" ] && [ -d "$OUTPUT_DIR" ]; then |
| Josh Bleecher Snyder | e3e886b | 2025-07-17 15:31:16 -0700 | [diff] [blame] | 23 | STORED_HASH=$(cat "$HASH_FILE") |
| 24 | if [ "$CURRENT_HASH" = "$STORED_HASH" ]; then |
| Josh Bleecher Snyder | e3e886b | 2025-07-17 15:31:16 -0700 | [diff] [blame] | 25 | exit 0 |
| 26 | fi |
| Josh Bleecher Snyder | 39eb24f | 2025-07-10 01:46:33 +0000 | [diff] [blame] | 27 | fi |
| 28 | |
| 29 | rm -rf "$OUTPUT_DIR" |
| 30 | unset GOOS GOARCH && go run ./cmd/genwebui -- "$OUTPUT_DIR" |
| 31 | echo "$CURRENT_HASH" >"$HASH_FILE" |