#!/bin/bash # Build release binaries for distribution # This script builds both Linux and Windows binaries (cross-compile) # # For Windows-only builds, use build-release.ps1 on Windows # For Linux-only builds, comment out the Windows section below set -e VERSION=${1:-$(git describe --tags --always)} RELEASE_DIR="release-artifacts" echo "Building Weevil $VERSION release binaries..." echo "" # Clean previous artifacts rm -rf "$RELEASE_DIR" mkdir -p "$RELEASE_DIR" # Build Linux binary (optimized) echo "Building Linux x86_64 binary..." cargo build --release strip target/release/weevil # Package Linux binary echo "Packaging Linux binaries..." cd target/release tar -czf "../../$RELEASE_DIR/weevil-${VERSION}-linux-x86_64.tar.gz" weevil zip -q "../../$RELEASE_DIR/weevil-${VERSION}-linux-x86_64.zip" weevil cd ../.. # Build Windows binary (cross-compile) echo "" echo "Building Windows x86_64 binary..." # Check if Windows target is installed if ! rustup target list | grep -q "x86_64-pc-windows-gnu (installed)"; then echo "Installing Windows target..." rustup target add x86_64-pc-windows-gnu fi # Check if MinGW is installed if ! command -v x86_64-w64-mingw32-gcc &> /dev/null; then echo "Warning: MinGW not found. Install with: sudo apt install mingw-w64" echo "Skipping Windows build." else cargo build --release --target x86_64-pc-windows-gnu x86_64-w64-mingw32-strip target/x86_64-pc-windows-gnu/release/weevil.exe # Package Windows binary echo "Packaging Windows binary..." cd target/x86_64-pc-windows-gnu/release zip -q "../../../$RELEASE_DIR/weevil-${VERSION}-windows-x86_64.zip" weevil.exe cd ../../.. fi # Generate checksums echo "" echo "Generating checksums..." cd "$RELEASE_DIR" sha256sum * > SHA256SUMS cd .. # Display results echo "" echo "═══════════════════════════════════════════════════════════" echo " ✓ Release artifacts built successfully!" echo "═══════════════════════════════════════════════════════════" echo "" echo "Artifacts in $RELEASE_DIR/:" ls -lh "$RELEASE_DIR" echo "" echo "Checksums:" cat "$RELEASE_DIR/SHA256SUMS" echo "" echo "Upload these files to your Gitea release:" echo " 1. Go to: Releases → $VERSION → Edit Release" echo " 2. Drag and drop files from $RELEASE_DIR/" echo " 3. Save" echo ""