#!/usr/bin/env bash set -e VERSION=$1 if [ -z "$VERSION" ]; then echo "Error: Missing version argument." echo "Usage: pnpm release " echo "Example: pnpm release 1.9.0" exit 1 fi # Ensure version does not have 'v' prefix for the variable VERSION=${VERSION#v} TAG="v$VERSION" echo "🚀 Starting release process for $TAG..." # 1. Sync versions across monorepo pnpm exec tsx scripts/sync-versions.ts -- "$TAG" # 2. Check if anything changed SYNC_FILES="package.json packages/*/package.json apps/*/package.json .env.example" CHANGES=$(git status --porcelain $SYNC_FILES) if [[ -n "$CHANGES" ]]; then echo "📝 Version sync made changes. Committing and tagging..." # Stage and commit git add $SYNC_FILES git commit -m "chore: release $TAG" --no-verify else echo "✨ Versions are already in sync." fi # 3. Tag and push echo "🏷️ Tagging $TAG..." git tag -f "$TAG" > /dev/null echo "🚀 Pushing branch and tag to origin..." CURRENT_BRANCH=$(git branch --show-current) if [ -n "$CURRENT_BRANCH" ]; then git push origin "$CURRENT_BRANCH" --no-verify fi git push origin "$TAG" --force --no-verify echo "" echo "✨ VERSIONS SYNCED & PUSHED SUCCESSFULLY ✨" echo "✅ Release $TAG is complete!" echo ""