Private
Public Access
1
0

Add Makefile with build targets and script to dynamically update cache version for client builds
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m20s

This commit is contained in:
Sebastian Unterschütz
2026-01-04 20:15:04 +01:00
parent 24e21387d9
commit 1417d3ceb2
2 changed files with 61 additions and 0 deletions

21
scripts/cache-version.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Generiert eine Cache-Version basierend auf aktuellem Timestamp
VERSION=$(date +%s%3N) # Unix timestamp in Millisekunden
JS_FILE="cmd/client/web/game.js"
HTML_FILE="cmd/client/web/index.html"
echo "🔄 Updating cache version to: $VERSION"
# Ersetze CACHE_VERSION in game.js und BUILD_VERSION in index.html
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' "s/const CACHE_VERSION = .*;/const CACHE_VERSION = $VERSION;/" "$JS_FILE"
sed -i '' "s/const BUILD_VERSION = .*;/const BUILD_VERSION = $VERSION;/" "$HTML_FILE"
else
# Linux
sed -i "s/const CACHE_VERSION = .*;/const CACHE_VERSION = $VERSION;/" "$JS_FILE"
sed -i "s/const BUILD_VERSION = .*;/const BUILD_VERSION = $VERSION;/" "$HTML_FILE"
fi
echo "✅ Cache version updated: $JS_FILE and $HTML_FILE"