PLWL/build.sh

39 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
VERSION=$(node -p "require('./package.json').version")
OUT="build/PLWL-$VERSION.tar.gz"
bash tools/svg2png.sh renderer/plwl.svg renderer/plwl.png 256
# 1. Electron runtime is the base of the release (the binary detects
# resources/app.asar automatically, so the whole app lives inside the asar).
if [ ! -d node_modules/electron/dist ]; then
npm install
fi
rm -rf build/dist
mkdir -p build/dist/PLWL
cp -r node_modules/electron/dist build/dist/PLWL/olcxja.plwl
mv build/dist/PLWL/olcxja.plwl/electron build/dist/PLWL/olcxja.plwl/olcxja.plwl
chmod +x build/dist/PLWL/olcxja.plwl/olcxja.plwl
# 2. Pack the app payload (code + renderer + bundled files) into app.asar.
STAGE=build/dist/.app-stage
mkdir -p "$STAGE"
cp -r src renderer files package.json "$STAGE/"
npx asar pack "$STAGE" build/dist/PLWL/olcxja.plwl/resources/app.asar
rm -rf "$STAGE"
# 3. Icon, installer and portable-shortcut helper.
cp renderer/plwl.png build/dist/PLWL/olcxja.plwl.png
cp tools/install.sh tools/createshortcut.sh build/dist/PLWL/
chmod +x build/dist/PLWL/install.sh build/dist/PLWL/createshortcut.sh
# 4. Tarball.
mkdir -p build
tar -czf "$OUT" -C build/dist PLWL
rm -rf build/dist
echo "Built $OUT"