From b4e06fa24b876a55b4d4936db1cb96000297808b Mon Sep 17 00:00:00 2001 From: Rivers Cuomo Date: Tue, 16 Jul 2024 07:35:22 -0700 Subject: [PATCH 1/2] update_version.sh --- update_version.sh | 43 +++++++++++++++++++++++++++---------------- web/index.html | 13 ------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/update_version.sh b/update_version.sh index 8dc8cdc..9bd470a 100644 --- a/update_version.sh +++ b/update_version.sh @@ -1,24 +1,35 @@ #!/bin/bash -# This is for website deployment -# Get the current timestamp -timestamp=$(date +%s) +# Navigate to the build directory +cd build/web -# Check if the web/index.html file exists -if [ ! -f "web/index.html" ]; then - echo "web/index.html not found. Exiting." - exit 1 -fi +# Generate a version hash based on the current timestamp +VERSION=$(date +%s | md5sum | cut -d' ' -f1) -echo "Updating version number for $(basename $(pwd))" +# Update flutter.js reference in index.html +sed -i.bak "s/flutter\.js/flutter.js?v=$VERSION/" index.html -# Make a backup of the original index.html file -cp web/index.html web/index.html.bak +# Update manifest.json reference +sed -i.bak "s/manifest\.json/manifest.json?v=$VERSION/" index.html -# Replace the main.dart.js reference with the new version number -sed -i "s/main\.dart\.js?v=[0-9]*/main.dart.js?v=$timestamp/" web/index.html +# Update favicon reference +sed -i.bak "s/favicon\.png/favicon.png?v=$VERSION/" index.html -# Remove the backup file -rm web/index.html.bak +# Update Icon-192.png reference +sed -i.bak "s/Icon-192\.png/Icon-192.png?v=$VERSION/" index.html -echo "Version number updated successfully" \ No newline at end of file +# Optionally, update other asset references +# sed -i.bak "s/assets\/fonts/assets\/fonts?v=$VERSION/g" index.html +# sed -i.bak "s/assets\/images/assets\/images?v=$VERSION/g" index.html + +# Remove the backup file created by sed +rm index.html.bak + +echo "Asset versioning completed. Version: $VERSION" + +# Optionally, update the serviceWorkerVersion in index.html +# This ensures that the service worker is updated with each deployment +sed -i.bak "s/const serviceWorkerVersion = null;/const serviceWorkerVersion = '$VERSION';/" index.html +rm index.html.bak + +echo "Service worker version updated to: $VERSION" \ No newline at end of file diff --git a/web/index.html b/web/index.html index bef78d0..d12f31c 100644 --- a/web/index.html +++ b/web/index.html @@ -2,19 +2,6 @@ - From e06f5ed0c2d3dcc29ddf3d6274af5e844597d370 Mon Sep 17 00:00:00 2001 From: Rivers Cuomo Date: Tue, 16 Jul 2024 07:39:22 -0700 Subject: [PATCH 2/2] web --- update_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_version.sh b/update_version.sh index 9bd470a..e894409 100644 --- a/update_version.sh +++ b/update_version.sh @@ -1,7 +1,7 @@ #!/bin/bash - +echo "Starting script" # Navigate to the build directory -cd build/web +cd web # Generate a version hash based on the current timestamp VERSION=$(date +%s | md5sum | cut -d' ' -f1)