#!/bin/bash # Generates a tarball of the current codebase for deployment # Output: /tmp/network-source.tar.gz # # If bin-linux/ exists (from make build-linux-all), it is included in the archive. # On the VPS, use scripts/extract-deploy.sh to extract source + place binaries. # # Usage: ./scripts/generate-source-archive.sh set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" OUTPUT="/tmp/network-source.tar.gz" cd "$PROJECT_ROOT" # Remove root-level binaries before archiving (they'll be rebuilt on VPS) rm -f gateway cli node orama-cli-linux 2>/dev/null # Check if pre-built binaries exist if [ -d "bin-linux" ] && [ "$(ls -A bin-linux 2>/dev/null)" ]; then echo "Generating source archive (with pre-built binaries)..." EXCLUDE_BIN="" else echo "Generating source archive (source only, no bin-linux/)..." EXCLUDE_BIN="--exclude=bin-linux/" fi tar czf "$OUTPUT" \ --exclude='.git' \ --exclude='node_modules' \ --exclude='*.log' \ --exclude='.DS_Store' \ --exclude='bin/' \ --exclude='dist/' \ --exclude='coverage/' \ --exclude='.claude/' \ --exclude='testdata/' \ --exclude='examples/' \ --exclude='*.tar.gz' \ $EXCLUDE_BIN \ . echo "Archive created: $OUTPUT" echo "Size: $(du -h $OUTPUT | cut -f1)" if [ -d "bin-linux" ] && [ "$(ls -A bin-linux 2>/dev/null)" ]; then echo "Includes pre-built binaries: $(ls bin-linux/ | tr '\n' ' ')" fi