breakout71/build.sh

57 lines
1.4 KiB
Bash
Raw Normal View History

2025-03-14 22:14:57 +01:00
#!/bin/bash
2025-03-14 22:21:47 +01:00
# the version number is just a unix timestamp in minutes
defaultVersionCode=$(($(date +%s) / 60))
versionCode=${1:-$defaultVersionCode}
2025-03-14 22:21:47 +01:00
2025-03-14 22:14:57 +01:00
source ~/.nvm/nvm.sh;
nvm install v21
nvm use v21
if [[ $(node --version) != v21* ]]; then
echo "run first: nvm use v21"
exit 1
fi
set -e
set -x
2025-04-04 14:49:44 +02:00
# clear output folders first, so that they are empty for failed builds
rm -rf ./build/*
rm -rf ./app/src/main/assets/*
2025-04-05 10:38:18 +02:00
rm -rf ./app/build/outputs/apk/release/*
rm -rf ./app/build/outputs/bundle/release/*
2025-03-14 22:14:57 +01:00
# Replace the version code and name in gradle for fdroid and play store
sed -i -e "s/^[[:space:]]*versionCode = .*/ versionCode = $versionCode/" \
-e "s/^[[:space:]]*versionName = .*/ versionName = \"$versionCode\"/" \
./app/build.gradle.kts
2025-03-16 17:45:29 +01:00
echo "\"$versionCode\"" > src/data/version.json
2025-03-14 22:14:57 +01:00
# Update service worker
2025-03-16 17:45:29 +01:00
sed -i -e "s/VERSION = .*/ VERSION = '$versionCode'/" ./src/PWA/sw-b71.js
2025-03-14 22:14:57 +01:00
# remove all exif metadata from pictures, because i think fdroid doesn't like that. odd
find -name '*.jp*g' -o -name '*.png' | xargs exiftool -all= -overwrite_original
2025-03-14 22:14:57 +01:00
npx prettier --write src/
2025-03-16 17:45:29 +01:00
npx jest
2025-04-04 14:49:44 +02:00
# Actual js app build
npx parcel build src/index.html --dist-dir build
2025-04-04 14:49:44 +02:00
# Add public files to the web version, but not to the apk
cp public/* build
2025-04-04 14:49:44 +02:00
# Add only index.html file to the apk, it should be enough
cp build/index.html ./app/src/main/assets/
2025-04-02 17:46:34 +02:00
2025-04-05 10:38:18 +02:00