#!/bin/bash set -e # Function to display usage usage() { echo "Usage: $0 " echo "Examples:" echo " $0 1.2.0" echo " $0 patch" exit 1 } # Check if argument is provided if [ -z "$1" ]; then usage fi INPUT_VERSION=$1 # Ensure git workspace is clean if [ -n "$(git status --porcelain)" ]; then echo "โŒ Git workspace is not clean. Please commit or stash changes first." exit 1 fi # Ensure we are on master branch CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) if [ "$CURRENT_BRANCH" != "master" ]; then echo "โš ๏ธ You are not on the master branch (current: $CURRENT_BRANCH)." read -p "Do you want to continue? (y/N) " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1 fi fi # Run tests echo "๐Ÿงช Running tests..." npm run test # Build Frontend echo "๐Ÿ—๏ธ Building frontend..." npm run build # Build Backend echo "๐Ÿ—๏ธ Building backend..." cd backend && npm run build && cd .. # Update version in package.json files echo "๐Ÿ”„ Updating version numbers..." npm version $INPUT_VERSION --no-git-tag-version --allow-same-version # Get the new version number NEW_VERSION=$(node -p "require('./package.json').version") echo "โœ… New version: $NEW_VERSION" # Update sub-packages cd frontend && npm version $NEW_VERSION --no-git-tag-version --allow-same-version && cd .. cd backend && npm version $NEW_VERSION --no-git-tag-version --allow-same-version && cd .. # Commit and Tag echo "๐Ÿ“ฆ Committing and tagging..." git add package.json frontend/package.json backend/package.json package-lock.json frontend/package-lock.json backend/package-lock.json git commit -m "chore(release): v$NEW_VERSION" git tag "v$NEW_VERSION" git push origin master git push origin "v$NEW_VERSION" echo "โœ… Version bumped and tagged: v$NEW_VERSION" # Build and Push echo "๐Ÿš€ Starting build and push process..." ./build-and-push.sh $NEW_VERSION echo "๐ŸŽ‰ Release v$NEW_VERSION completed successfully!"