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
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m20s
This commit is contained in:
40
Makefile
Normal file
40
Makefile
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
.PHONY: build-wasm build-native build-server clean update-cache
|
||||||
|
|
||||||
|
# Build WASM Client mit Cache-Version Update
|
||||||
|
build-wasm: update-cache
|
||||||
|
@echo "🔨 Building WASM Client..."
|
||||||
|
cd cmd/client && GOOS=js GOARCH=wasm go build -o web/main.wasm
|
||||||
|
@echo "✅ WASM build complete: cmd/client/web/main.wasm"
|
||||||
|
|
||||||
|
# Update Cache-Version vor dem Build
|
||||||
|
update-cache:
|
||||||
|
@echo "🔄 Updating cache version..."
|
||||||
|
@./scripts/cache-version.sh
|
||||||
|
|
||||||
|
# Build Native Client
|
||||||
|
build-native:
|
||||||
|
@echo "🔨 Building Native Client..."
|
||||||
|
cd cmd/client && go build -o ../../build/client
|
||||||
|
@echo "✅ Native client build complete: build/client"
|
||||||
|
|
||||||
|
# Build Server
|
||||||
|
build-server:
|
||||||
|
@echo "🔨 Building Server..."
|
||||||
|
cd cmd/server && go build -o ../../build/server
|
||||||
|
@echo "✅ Server build complete: build/server"
|
||||||
|
|
||||||
|
# Build All
|
||||||
|
build-all: build-wasm build-native build-server
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
clean:
|
||||||
|
@echo "🧹 Cleaning build artifacts..."
|
||||||
|
rm -f cmd/client/web/main.wasm
|
||||||
|
rm -rf build/
|
||||||
|
@echo "✅ Clean complete"
|
||||||
|
|
||||||
|
# Development: Build WASM and run local server
|
||||||
|
dev: build-wasm
|
||||||
|
@echo "🚀 Starting development server..."
|
||||||
|
@echo "Open http://localhost:8080 in your browser"
|
||||||
|
cd cmd/client/web && python3 -m http.server 8080
|
||||||
21
scripts/cache-version.sh
Executable file
21
scripts/cache-version.sh
Executable 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"
|
||||||
Reference in New Issue
Block a user