summaryrefslogtreecommitdiff
path: root/process-static
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2022-02-19 11:56:00 -0500
committerDaniel Micay <danielmicay@gmail.com>2022-02-19 12:00:06 -0500
commit42919855d544be470a65f4f631de9bbfe2c62876 (patch)
treea960c7d3dff9692a3d8f0240a5fb82f733da20f1 /process-static
parent83a3aaf65d69049c8a1003b688a8ed49c575c885 (diff)
add scripting for auto-generating releases listing
Diffstat (limited to 'process-static')
-rwxr-xr-xprocess-static21
1 files changed, 19 insertions, 2 deletions
diff --git a/process-static b/process-static
index 86e41fcf..88f04d04 100755
--- a/process-static
+++ b/process-static
@@ -5,6 +5,10 @@ shopt -s dotglob extglob globstar
export PATH="$PWD/node_modules/.bin:$PATH"
+# can use file:// to avoid network requests
+[[ -f releases-base ]] && RELEASES_BASE=$(cat releases-base)
+RELEASES_BASE=${RELEASES_BASE:-https://releases.grapheneos.org}
+
rm -rf nginx-tmp
cp -a nginx nginx-tmp
@@ -24,7 +28,7 @@ find static-tmp -name '*.css' -exec csso {} -o {} \;
eslint static-tmp/**/!(fastboot.min.m|z-worker-pako.|pako_inflate.min.|)js
find static-tmp -name '*.js' -exec terser --ecma 2021 --module -cmo {} {} \;
-replace=""
+replace=
for file in static-tmp/**/*.css static-tmp/js/*.js static-tmp/mask-icon.svg; do
hash=$(sha256sum "$file" | head -c 8)
sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A)
@@ -40,9 +44,22 @@ for file in static-tmp/**/*.css static-tmp/js/*.js static-tmp/mask-icon.svg; do
replace+=";s@{{integrity|/${file#*/}}}@${sri_hash}@g"
replace+=";s@{{path|/${file#*/}}}@/${dest#*/}@g"
done
-
sed -i "$replace" static-tmp/**/*.html nginx-tmp/nginx.conf nginx-tmp/snippets/preload.conf
+replace=
+devices=(raven oriole barbet redfin bramble sunfish coral flame bonito sargo crosshatch blueline)
+channels=(stable beta)
+for device in ${devices[@]}; do
+ for channel in ${channels[@]}; do
+ metadata=$(curl -s $RELEASES_BASE/$device-$channel)
+ build_id=$(echo -n $metadata | cut -d ' ' -f 3)
+ build_number=$(echo -n $metadata | cut -d ' ' -f 1)
+ replace+=";s@{{$device-$channel-BUILD_ID}}@$build_id@g"
+ replace+=";s@{{$device-$channel-BUILD_NUMBER}}@$build_number@g"
+ done
+done
+sed -i "$replace" static-tmp/releases.html
+
gixy nginx-tmp/nginx.conf
xmllint --noout static-tmp/**/*.html