PREFIX="mycelium" echo "Starting build..." SOURCE=${BASH_SOURCE[0]} DIR_OF_THIS_SCRIPT="$( dirname "$SOURCE" )" ABS_DIR_OF_SCRIPT="$( realpath $DIR_OF_THIS_SCRIPT )" # Check if tailwindcss executable exists, if not, download and install it if [[ ! -f "tailwindcss" ]]; then echo "Installing & building tailwind..." ASSET="tailwindcss" if [[ "$OSTYPE" == "linux-gnu"* ]]; then ASSET="$ASSET-linux" elif [[ "$OSTYPE" == "darwin"* ]]; then ASSET="$ASSET-macos" fi if [[ "$(uname -m)" == "x86_64"* ]]; then ASSET="$ASSET-x64" elif [[ "$(uname -m)" == "arm64"* ]]; then ASSET="$ASSET-arm64" fi curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/${ASSET}" chmod +x $ASSET mv $ASSET tailwindcss else echo "tailwindcss already exists, skipping installation." fi # initialized and configures tailwind if not configured echo "Initializing tailwind..." if [[ ! -f "tailwind.config.js" ]] then ./tailwindcss init sed -i '' "s| content: \\[\\],| content: \\['./templates/**/*.html'\\],|g" tailwind.config.js fi # compiles tailwind css for prod & builds project echo "Compiling tailwindcss and building zola project..." rm -rf public static/css ./tailwindcss -i css/index.css -o ./static/css/index.css --minify # Auto-detect deployment environment based on git branch CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) echo "Detected git branch: $CURRENT_BRANCH" if [ "$CURRENT_BRANCH" = "master" ]; then # Production deployment (www.mycelium.threefold.io) echo "Building for PRODUCTION environment..." BASE_URL="https://www.mycelium.threefold.io/" DEPLOY_PATH="root@threefold.info:/root/hero/www/info/$PREFIX/" elif [ "$CURRENT_BRANCH" = "development" ]; then # Staging deployment (www2.mycelium.threefold.io) echo "Building for STAGING environment..." BASE_URL="https://www2.mycelium.threefold.io/" DEPLOY_PATH="root@threefold.info:/root/hero/www/info/$PREFIX/" else # Fallback for other branches (local development mode) echo "Building for LOCAL/OTHER branch environment..." BASE_URL="/mycelium/" DEPLOY_PATH="${HOME}/hero/var/www/$PREFIX/" fi echo "Using base_url: $BASE_URL" sed "s|base_url = \"BASEURL\"|base_url = \"$BASE_URL\"|" config.templ.toml > config.toml zola --root $ABS_DIR_OF_SCRIPT build rsync -avz --delete public/ "$DEPLOY_PATH"