feat(versioning): update asset paths and versioning logic in HTML and scripts
This commit is contained in:
2
.github/workflows/build-apk.yml
vendored
2
.github/workflows/build-apk.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
working-directory: android
|
working-directory: android
|
||||||
run: ./gradlew assembleDebug
|
run: ./gradlew assembleDebug
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload APK>
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: impostor-game-debug
|
name: impostor-game-debug
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- 'script.js'
|
- 'www/script.js'
|
||||||
- 'styles.css'
|
- 'www/styles.css'
|
||||||
- 'logo.png'
|
- 'www/logo.png'
|
||||||
- 'index.html'
|
- 'www/index.html'
|
||||||
- 'version-assets.sh'
|
- 'version-assets.sh'
|
||||||
- '.github/workflows/version-assets.yml'
|
- '.github/workflows/version-assets.yml'
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Delete old versioned assets
|
- name: Delete old versioned assets
|
||||||
run: |
|
run: |
|
||||||
echo "🗑️ Borrando archivos hasheados antiguos..."
|
echo "🗑️ Borrando archivos hasheados antiguos..."
|
||||||
rm -f *.*.js *.*.css *.*.png || true
|
rm -f www/*.*.js www/*.*.css www/*.*.png || true
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
- name: Run asset versioning
|
- name: Run asset versioning
|
||||||
@@ -49,6 +49,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --local user.email "ci@dariosevilla.es"
|
git config --local user.email "ci@dariosevilla.es"
|
||||||
git config --local user.name "CI Action"
|
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 commit -m "chore: update asset versions [skip ci]"
|
||||||
git push
|
git push
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.1 KiB |
1347
script.f88d8968.js
1347
script.f88d8968.js
File diff suppressed because it is too large
Load Diff
1829
styles.1a37b506.css
1829
styles.1a37b506.css
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,9 @@ set -e
|
|||||||
echo "🚀 Iniciando versionado de archivos estáticos..."
|
echo "🚀 Iniciando versionado de archivos estáticos..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Directorio de trabajo
|
||||||
|
WWW_DIR="www"
|
||||||
|
|
||||||
# Archivos a versionar
|
# Archivos a versionar
|
||||||
ASSETS=("script.js" "styles.css" "logo.png")
|
ASSETS=("script.js" "styles.css" "logo.png")
|
||||||
HTML_FILE="index.html"
|
HTML_FILE="index.html"
|
||||||
@@ -28,26 +31,29 @@ get_versioned_name() {
|
|||||||
|
|
||||||
# Limpiar archivos versionados antiguos
|
# Limpiar archivos versionados antiguos
|
||||||
echo "🗑️ Limpiando versiones antiguas..."
|
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 ""
|
echo ""
|
||||||
|
|
||||||
# Crear backup del HTML
|
# Crear backup del HTML
|
||||||
cp "$HTML_FILE" "${HTML_FILE}.bak"
|
cp "$WWW_DIR/$HTML_FILE" "$WWW_DIR/${HTML_FILE}.bak"
|
||||||
|
|
||||||
# Versionar cada archivo
|
# Versionar cada archivo
|
||||||
for asset in "${ASSETS[@]}"; do
|
for asset in "${ASSETS[@]}"; do
|
||||||
if [[ ! -f "$asset" ]]; then
|
asset_path="$WWW_DIR/$asset"
|
||||||
echo "⚠️ Advertencia: $asset no encontrado, saltando..."
|
|
||||||
|
if [[ ! -f "$asset_path" ]]; then
|
||||||
|
echo "⚠️ Advertencia: $asset_path no encontrado, saltando..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generar hash
|
# Generar hash
|
||||||
hash=$(generate_hash "$asset")
|
hash=$(generate_hash "$asset_path")
|
||||||
versioned=$(get_versioned_name "$asset" "$hash")
|
versioned=$(get_versioned_name "$asset" "$hash")
|
||||||
|
versioned_path="$WWW_DIR/$versioned"
|
||||||
|
|
||||||
# Copiar archivo con versión
|
# Copiar archivo con versión
|
||||||
echo "📦 Versionando: $asset → $versioned"
|
echo "📦 Versionando: $asset → $versioned"
|
||||||
cp "$asset" "$versioned"
|
cp "$asset_path" "$versioned_path"
|
||||||
|
|
||||||
# Obtener nombre base y extensión para el patrón
|
# Obtener nombre base y extensión para el patrón
|
||||||
base="${asset%.*}"
|
base="${asset%.*}"
|
||||||
@@ -56,14 +62,14 @@ for asset in "${ASSETS[@]}"; do
|
|||||||
# Actualizar referencia en HTML (busca versión original o hasheada)
|
# Actualizar referencia en HTML (busca versión original o hasheada)
|
||||||
case "$asset" in
|
case "$asset" in
|
||||||
*.js)
|
*.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)
|
*.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)
|
*.png)
|
||||||
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"
|
||||||
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"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -72,9 +78,9 @@ for asset in "${ASSETS[@]}"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Limpiar backup
|
# Limpiar backup
|
||||||
rm -f "${HTML_FILE}.bak"
|
rm -f "$WWW_DIR/${HTML_FILE}.bak"
|
||||||
|
|
||||||
echo "✅ Versionado completado exitosamente!"
|
echo "✅ Versionado completado exitosamente!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "📋 Archivos versionados:"
|
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)"
|
||||||
|
|||||||
@@ -77,17 +77,17 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<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 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="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">
|
<link rel="manifest" href="manifest.webmanifest">
|
||||||
<meta name="theme-color" content="#ff4444">
|
<meta name="theme-color" content="#ff4444">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<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-status-bar-style" content="black-translucent">
|
||||||
<meta name="apple-mobile-web-app-title" content="Impostor">
|
<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>
|
<script defer src="https://analytics.dariosevilla.es/script.js" data-website-id="0520a008-d309-477f-9742-b4a674ac42eb"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
<!-- Welcome screen -->
|
<!-- Welcome screen -->
|
||||||
<div id="welcome-screen" class="screen active">
|
<div id="welcome-screen" class="screen active">
|
||||||
<div class="welcome-content">
|
<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>
|
<h1 class="welcome-title">Juego del Impostor</h1>
|
||||||
<p class="welcome-subtitle">¿Podrás descubrir quién es el impostor?</p>
|
<p class="welcome-subtitle">¿Podrás descubrir quién es el impostor?</p>
|
||||||
<div class="welcome-buttons">
|
<div class="welcome-buttons">
|
||||||
@@ -265,7 +265,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.c9dd22de.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user