#!/bin/bash set -e # PriceForge Release Build Script # Creates binaries for all platforms and packages them for release # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Get version from git VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") if [[ $VERSION == *"dirty"* ]]; then echo -e "${RED}✗ Error: Working directory has uncommitted changes${NC}" echo " Commit your changes first" exit 1 fi echo -e "${GREEN}Building PriceForge version: ${VERSION}${NC}" echo "" # Create release directory RELEASE_DIR="releases/${VERSION}" mkdir -p "${RELEASE_DIR}" # Build for all platforms echo -e "${YELLOW}→ Building binaries...${NC}" make build-all # Package binaries with checksums echo "" echo -e "${YELLOW}→ Creating release packages...${NC}" # Linux AMD64 if [ -f "bin/pfs-linux-amd64" ]; then cd bin tar -czf "../${RELEASE_DIR}/pfs-${VERSION}-linux-amd64.tar.gz" pfs-linux-amd64 cd .. echo -e "${GREEN} ✓ pfs-${VERSION}-linux-amd64.tar.gz${NC}" fi # macOS Intel if [ -f "bin/pfs-darwin-amd64" ]; then cd bin tar -czf "../${RELEASE_DIR}/pfs-${VERSION}-darwin-amd64.tar.gz" pfs-darwin-amd64 cd .. echo -e "${GREEN} ✓ pfs-${VERSION}-darwin-amd64.tar.gz${NC}" fi # macOS Apple Silicon if [ -f "bin/pfs-darwin-arm64" ]; then cd bin tar -czf "../${RELEASE_DIR}/pfs-${VERSION}-darwin-arm64.tar.gz" pfs-darwin-arm64 cd .. echo -e "${GREEN} ✓ pfs-${VERSION}-darwin-arm64.tar.gz${NC}" fi # Windows AMD64 if [ -f "bin/pfs-windows-amd64.exe" ]; then cd bin zip -q "../${RELEASE_DIR}/pfs-${VERSION}-windows-amd64.zip" pfs-windows-amd64.exe cd .. echo -e "${GREEN} ✓ pfs-${VERSION}-windows-amd64.zip${NC}" fi # Generate checksums echo "" echo -e "${YELLOW}→ Generating checksums...${NC}" cd "${RELEASE_DIR}" shasum -a 256 *.tar.gz *.zip > SHA256SUMS.txt 2>/dev/null || shasum -a 256 * | grep -v SHA256SUMS > SHA256SUMS.txt cd ../.. echo -e "${GREEN} ✓ SHA256SUMS.txt${NC}" # List release files echo "" echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${GREEN}Release ${VERSION} built successfully!${NC}" echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo "" echo "Files in ${RELEASE_DIR}:" ls -lh "${RELEASE_DIR}" echo "" # Show next steps echo -e "${YELLOW}Next steps:${NC}" echo " 1. Create git tag:" echo " git tag -a ${VERSION} -m \"Release ${VERSION}\"" echo "" echo " 2. Push tag to remote:" echo " git push origin ${VERSION}" echo "" echo " 3. Create release on git.mchus.pro:" echo " - Go to: https://git.mchus.pro/mchus/PriceForge/releases" echo " - Click 'New Release'" echo " - Select tag: ${VERSION}" echo " - Upload files from: ${RELEASE_DIR}/" echo "" echo -e "${GREEN}Done!${NC}"