mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-22 03:02:35 +00:00
Addresses #304 - Eliminates redirect loops and path issues by embedding the frontend directly in the Go binary using go:embed - Frontend is now embedded at compile time, no separate files needed - Simplified tarball structure - just the binary and config files - No more path searching or frontend directory issues - Works consistently across all installation methods - Smaller deployment footprint and simpler installation This change makes Pulse a true single-binary deployment, eliminating the complexity of managing separate frontend files and the issues that arose from different installation structures.
126 lines
No EOL
3.3 KiB
Bash
Executable file
126 lines
No EOL
3.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Build script for Pulse releases
|
|
# Creates release archives for different architectures
|
|
|
|
set -euo pipefail
|
|
|
|
# Use Go 1.23 if available
|
|
if [ -x /usr/local/go/bin/go ]; then
|
|
export PATH=/usr/local/go/bin:$PATH
|
|
fi
|
|
|
|
VERSION=${1:-$(cat VERSION)}
|
|
BUILD_DIR="build"
|
|
RELEASE_DIR="release"
|
|
|
|
echo "Building Pulse v${VERSION}..."
|
|
|
|
# Clean previous builds
|
|
rm -rf $BUILD_DIR $RELEASE_DIR
|
|
mkdir -p $BUILD_DIR $RELEASE_DIR
|
|
|
|
# Build frontend
|
|
echo "Building frontend..."
|
|
cd frontend-modern
|
|
npm ci
|
|
npm run build
|
|
cd ..
|
|
|
|
# Copy frontend to api directory for embedding
|
|
echo "Copying frontend for embedding..."
|
|
rm -rf internal/api/frontend-modern
|
|
cp -r frontend-modern internal/api/
|
|
|
|
# Build for different architectures
|
|
declare -A builds=(
|
|
["linux-amd64"]="GOOS=linux GOARCH=amd64"
|
|
["linux-arm64"]="GOOS=linux GOARCH=arm64"
|
|
["linux-armv7"]="GOOS=linux GOARCH=arm GOARM=7"
|
|
)
|
|
|
|
for build_name in "${!builds[@]}"; do
|
|
echo "Building for $build_name..."
|
|
|
|
# Get build environment
|
|
build_env="${builds[$build_name]}"
|
|
|
|
# Build binary
|
|
env $build_env go build \
|
|
-ldflags="-s -w -X github.com/rcourtman/pulse-go-rewrite/internal/updates.version=${VERSION}" \
|
|
-trimpath \
|
|
-o "$BUILD_DIR/pulse-$build_name" \
|
|
./cmd/pulse
|
|
|
|
# Create release archive
|
|
tar_name="pulse-v${VERSION}-${build_name}.tar.gz"
|
|
|
|
# Create staging directory - simplified structure with embedded frontend
|
|
staging_dir="$BUILD_DIR/pulse-staging"
|
|
rm -rf "$staging_dir"
|
|
mkdir -p "$staging_dir"
|
|
|
|
# Copy files - no frontend needed as it's embedded
|
|
cp "$BUILD_DIR/pulse-$build_name" "$staging_dir/pulse"
|
|
cp README.md LICENSE install.sh "$staging_dir/"
|
|
echo "$VERSION" > "$staging_dir/VERSION"
|
|
|
|
# Create tarball
|
|
cd "$staging_dir"
|
|
tar -czf "../../$RELEASE_DIR/$tar_name" .
|
|
cd ../..
|
|
|
|
# Cleanup staging
|
|
rm -rf "$staging_dir"
|
|
|
|
echo "Created $RELEASE_DIR/$tar_name"
|
|
done
|
|
|
|
# Create checksums
|
|
cd $RELEASE_DIR
|
|
sha256sum *.tar.gz > checksums.txt
|
|
cd ..
|
|
|
|
echo "Release build complete! Files in $RELEASE_DIR/"
|
|
ls -lh $RELEASE_DIR/
|
|
|
|
# Create universal release tarball with all architectures
|
|
echo "Creating universal release tarball..."
|
|
universal_staging="$BUILD_DIR/pulse-staging"
|
|
rm -rf "$universal_staging"
|
|
mkdir -p "$universal_staging/bin/frontend-modern"
|
|
|
|
# Copy all architecture binaries to bin/
|
|
for build_name in "${!builds[@]}"; do
|
|
cp "$BUILD_DIR/pulse-$build_name" "$universal_staging/bin/pulse-$build_name"
|
|
done
|
|
|
|
# Use amd64 binary as default 'pulse' for seamless usage
|
|
cp "$BUILD_DIR/pulse-linux-amd64" "$universal_staging/bin/pulse"
|
|
chmod +x "$universal_staging/bin/pulse"
|
|
|
|
# Copy common files
|
|
cp -r frontend-modern/dist "$universal_staging/bin/frontend-modern/"
|
|
cp README.md LICENSE install.sh "$universal_staging/" 2>/dev/null || true
|
|
echo "$VERSION" > "$universal_staging/VERSION"
|
|
|
|
# Create first-run cleanup flag
|
|
touch "$universal_staging/.first-run-cleanup"
|
|
|
|
# Create the universal tarball (this is what the community script expects)
|
|
cd "$universal_staging"
|
|
tar -czf "../../$RELEASE_DIR/pulse-v${VERSION}.tar.gz" .
|
|
cd ../..
|
|
|
|
# Cleanup
|
|
rm -rf "$universal_staging"
|
|
|
|
echo "Created universal release: $RELEASE_DIR/pulse-v${VERSION}.tar.gz"
|
|
|
|
# Update checksums
|
|
cd $RELEASE_DIR
|
|
sha256sum *.tar.gz > checksums.txt
|
|
cd ..
|
|
|
|
echo "Final release contents:"
|
|
ls -lh $RELEASE_DIR/ |