Private
Public Access
1
0
Files
EscapeFromTeacher/scripts/cache-version.sh
Sebastian Unterschütz 1417d3ceb2
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m20s
Add Makefile with build targets and script to dynamically update cache version for client builds
2026-01-04 20:15:04 +01:00

22 lines
803 B
Bash
Executable File

#!/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"