feat(versioning): update asset paths and versioning logic in HTML and scripts
Some checks failed
Build Android APK / build (push) Has been cancelled
Version Static Assets / version-assets (push) Has been cancelled

This commit is contained in:
2026-01-22 08:32:14 +01:00
parent 236112a7ba
commit e30aa089e4
9 changed files with 32 additions and 3202 deletions

View File

@@ -38,7 +38,7 @@ jobs:
working-directory: android
run: ./gradlew assembleDebug
- name: Upload APK
- name: Upload APK>
uses: actions/upload-artifact@v4
with:
name: impostor-game-debug

View File

@@ -5,10 +5,10 @@ on:
branches:
- main
paths:
- 'script.js'
- 'styles.css'
- 'logo.png'
- 'index.html'
- 'www/script.js'
- 'www/styles.css'
- 'www/logo.png'
- 'www/index.html'
- 'version-assets.sh'
- '.github/workflows/version-assets.yml'
@@ -26,7 +26,7 @@ jobs:
- name: Delete old versioned assets
run: |
echo "🗑️ Borrando archivos hasheados antiguos..."
rm -f *.*.js *.*.css *.*.png || true
rm -f www/*.*.js www/*.*.css www/*.*.png || true
git add -A
- name: Run asset versioning
@@ -49,6 +49,6 @@ jobs:
run: |
git config --local user.email "ci@dariosevilla.es"
git config --local user.name "CI Action"
git add *.*.js *.*.css *.*.png index.html
git add www/*.*.js www/*.*.css www/*.*.png www/index.html
git commit -m "chore: update asset versions [skip ci]"
git push

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,9 @@ set -e
echo "🚀 Iniciando versionado de archivos estáticos..."
echo ""
# Directorio de trabajo
WWW_DIR="www"
# Archivos a versionar
ASSETS=("script.js" "styles.css" "logo.png")
HTML_FILE="index.html"
@@ -28,26 +31,29 @@ get_versioned_name() {
# Limpiar archivos versionados antiguos
echo "🗑️ Limpiando versiones antiguas..."
rm -f *.*.js *.*.css *.*.png 2>/dev/null || true
rm -f "$WWW_DIR"/*.*.js "$WWW_DIR"/*.*.css "$WWW_DIR"/*.*.png 2>/dev/null || true
echo ""
# Crear backup del HTML
cp "$HTML_FILE" "${HTML_FILE}.bak"
cp "$WWW_DIR/$HTML_FILE" "$WWW_DIR/${HTML_FILE}.bak"
# Versionar cada archivo
for asset in "${ASSETS[@]}"; do
if [[ ! -f "$asset" ]]; then
echo "⚠️ Advertencia: $asset no encontrado, saltando..."
asset_path="$WWW_DIR/$asset"
if [[ ! -f "$asset_path" ]]; then
echo "⚠️ Advertencia: $asset_path no encontrado, saltando..."
continue
fi
# Generar hash
hash=$(generate_hash "$asset")
hash=$(generate_hash "$asset_path")
versioned=$(get_versioned_name "$asset" "$hash")
versioned_path="$WWW_DIR/$versioned"
# Copiar archivo con versión
echo "📦 Versionando: $asset$versioned"
cp "$asset" "$versioned"
cp "$asset_path" "$versioned_path"
# Obtener nombre base y extensión para el patrón
base="${asset%.*}"
@@ -56,14 +62,14 @@ for asset in "${ASSETS[@]}"; do
# Actualizar referencia en HTML (busca versión original o hasheada)
case "$asset" in
*.js)
sed -i -E "s|src=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|src=\"${versioned}\"|g" "$HTML_FILE"
sed -i -E "s|src=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|src=\"${versioned}\"|g" "$WWW_DIR/$HTML_FILE"
;;
*.css)
sed -i -E "s|href=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|href=\"${versioned}\"|g" "$HTML_FILE"
sed -i -E "s|href=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|href=\"${versioned}\"|g" "$WWW_DIR/$HTML_FILE"
;;
*.png)
sed -i -E "s|href=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|href=\"${versioned}\"|g" "$HTML_FILE"
sed -i -E "s|src=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|src=\"${versioned}\"|g" "$HTML_FILE"
sed -i -E "s|href=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|href=\"${versioned}\"|g" "$WWW_DIR/$HTML_FILE"
sed -i -E "s|src=\"${base}(\.[a-f0-9]{8})?\.${ext}\"|src=\"${versioned}\"|g" "$WWW_DIR/$HTML_FILE"
;;
esac
@@ -72,9 +78,9 @@ for asset in "${ASSETS[@]}"; do
done
# Limpiar backup
rm -f "${HTML_FILE}.bak"
rm -f "$WWW_DIR/${HTML_FILE}.bak"
echo "✅ Versionado completado exitosamente!"
echo ""
echo "📋 Archivos versionados:"
ls -1 *.*.{js,css,png} 2>/dev/null || echo " (ninguno)"
ls -1 "$WWW_DIR"/*.*.{js,css,png} 2>/dev/null || echo " (ninguno)"

View File

@@ -77,17 +77,17 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Crimson+Text:wght@600;700&family=Courier+Prime:wght@400;700&family=JetBrains+Mono:wght@400;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.1a37b506.css">
<link rel="stylesheet" href="styles.2e5df802.css">
<link rel="icon" type="image/png" href="logo.78f51359.png">
<link rel="sitemap" type="application/xml" href="/www/sitemap.xml">
<link rel="stylesheet" href="styles.2e5df802.css">
<link rel="icon" type="image/png" href="logo.78f51359.png">
<link rel="sitemap" type="application/xml" href="/sitemap.xml">
<link rel="stylesheet" href="styles.css">
<link rel="icon" type="image/png" href="logo.png">
<link rel="manifest" href="manifest.webmanifest">
<meta name="theme-color" content="#ff4444">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Impostor">
<link rel="apple-touch-icon" href="logo.png">
<link rel="apple-touch-icon" href="logo.78f51359.png">
<script defer src="https://analytics.dariosevilla.es/script.js" data-website-id="0520a008-d309-477f-9742-b4a674ac42eb"></script>
</head>
<body>
@@ -117,7 +117,7 @@
<!-- Welcome screen -->
<div id="welcome-screen" class="screen active">
<div class="welcome-content">
<img src="logo.png" alt="Logo" class="welcome-logo">
<img src="logo.78f51359.png" alt="Logo" class="welcome-logo">
<h1 class="welcome-title">Juego del Impostor</h1>
<p class="welcome-subtitle">¿Podrás descubrir quién es el impostor?</p>
<div class="welcome-buttons">
@@ -265,7 +265,7 @@
</div>
</div>
<script src="script.js"></script>
<script src="script.c9dd22de.js"></script>
</body>
</html>