Notes/bin/build-server.sh

77 lines
1.8 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
2024-07-22 21:33:07 +03:00
set -e # Fail on any command error
# Debug output
echo "Matrix Arch: $MATRIX_ARCH"
# Detect architecture from matrix input, fallback to system architecture
if [ -n "$MATRIX_ARCH" ]; then
ARCH=$MATRIX_ARCH
else
ARCH=$(uname -m)
# Convert system architecture to our naming convention
case $ARCH in
x86_64) ARCH="x64" ;;
aarch64) ARCH="arm64" ;;
esac
fi
# Debug output
echo "Selected Arch: $ARCH"
# Set Node.js version and architecture-specific filename
NODE_VERSION=20.15.1
NODE_ARCH=$ARCH
# Debug output
echo "Node arch: $NODE_ARCH"
# Special case for x64 in Node.js downloads
if [ "$NODE_ARCH" = "x64" ]; then
NODE_FILENAME="x64"
elif [ "$NODE_ARCH" = "arm64" ]; then
NODE_FILENAME="arm64"
fi
# Debug output
echo "Node filename: $NODE_FILENAME"
PKG_DIR=dist/trilium-linux-${ARCH}-server
echo "Package directory: $PKG_DIR"
2019-10-11 21:22:59 +02:00
if [ "$1" != "DONTCOPY" ]
then
# Need to modify copy-trilium.sh to accept the target directory
./bin/copy-trilium.sh "$PKG_DIR"
2019-10-11 21:22:59 +02:00
fi
2019-10-11 21:22:59 +02:00
cd dist
wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz
tar xfJ node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz
rm node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz
2019-10-11 21:22:59 +02:00
cd ..
mv dist/node-v${NODE_VERSION}-linux-${NODE_FILENAME} $PKG_DIR/node
2020-08-26 23:51:30 +02:00
rm -r $PKG_DIR/node/lib/node_modules/npm
rm -r $PKG_DIR/node/include/node
2020-08-26 23:51:30 +02:00
2019-10-11 21:22:59 +02:00
rm -r $PKG_DIR/node_modules/electron*
2024-09-08 17:40:05 +03:00
rm -r $PKG_DIR/electron*.js
printf "#!/bin/sh\n./node/bin/node src/main" > $PKG_DIR/trilium.sh
2019-10-11 21:22:59 +02:00
chmod 755 $PKG_DIR/trilium.sh
cp bin/tpl/anonymize-database.sql $PKG_DIR/
cp -r translations $PKG_DIR/
cp -r dump-db $PKG_DIR/
rm -rf $PKG_DIR/dump-db/node_modules
2019-10-11 21:22:59 +02:00
VERSION=`jq -r ".version" package.json`
2019-10-11 21:22:59 +02:00
cd dist
2019-01-12 19:48:45 +01:00
tar cJf trilium-linux-${ARCH}-server-${VERSION}.tar.xz trilium-linux-${ARCH}-server