#!/bin/bash # Build hyprcrd distribution ZIP with version bump set -e if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "Usage: ./dist.sh [--patch|--minor|--major]" echo "" echo " --patch bump patch version (default) 0.1.1 → 0.1.2" echo " --minor bump minor version 0.1.2 → 0.2.0" echo " --major bump major version 0.2.0 → 1.0.0" echo "" echo "Builds Tailwind CSS, bumps version in config.php," echo "and creates hyprcrd-{version}.zip with all source files." exit 0 fi cd "$(dirname "$0")" # Read current version CURRENT=$(grep "APP_VERSION" config.php | grep -oP "'[^']+'" | tail -1 | tr -d "'") IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" # Bump: --major, --minor, or patch (default) case "${1:-patch}" in --major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; --minor) MINOR=$((MINOR + 1)); PATCH=0 ;; *) PATCH=$((PATCH + 1)) ;; esac VERSION="${MAJOR}.${MINOR}.${PATCH}" sed -i "s/APP_VERSION', '${CURRENT}'/APP_VERSION', '${VERSION}'/" config.php echo "Version: ${CURRENT} → ${VERSION}" DIST="hyprcrd-${VERSION}.zip" # Rebuild Tailwind if CLI exists if [ -x ./tailwindcss ]; then echo "Building Tailwind CSS..." ./tailwindcss --input public/css/tailwind.css --output public/css/tailwind.out.css --content "public/index.php,public/js/**/*.js" --minify fi echo "Creating ${DIST}..." zip -r "$DIST" \ config.php \ Dockerfile \ docker-entrypoint.sh \ README.md \ dist.sh \ .gitignore \ src/ \ public/ \ -x "public/uploads/*" \ -x "public/uploads/.gitkeep" \ -x "public/css/tailwind.css" # Add empty dirs with gitkeep mkdir -p /tmp/hyprcrd-dist/data mkdir -p /tmp/hyprcrd-dist/public/uploads touch /tmp/hyprcrd-dist/data/.gitkeep touch /tmp/hyprcrd-dist/public/uploads/.gitkeep cd /tmp/hyprcrd-dist zip -r "$OLDPWD/$DIST" data/.gitkeep public/uploads/.gitkeep cd "$OLDPWD" rm -rf /tmp/hyprcrd-dist echo "Done: ${DIST} ($(du -h "$DIST" | cut -f1))"