#!/usr/bin/env bash set -e # Prompt for version bump type read -p "Select version bump (major/minor/patch): " bump if [[ ! "$bump" =~ ^(major|minor|patch)$ ]]; then echo "Invalid choice. Must be 'major', 'minor', or 'patch'." exit 1 fi # Run tests echo "Running test suite..." npm test # Build the project echo "Building the project..." npm run build # Bump version echo "Bumping version ($bump)..." npm version "$bump" -m "chore(release): %s" # Show git status git status # Confirm publishing read -p "Proceed with npm publish? (y/N): " confirm if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then echo "Publish aborted." exit 0 fi # Prompt for OTP read -p "Enter npm OTP (leave blank if not using 2FA): " otp if [[ -n "$otp" ]]; then npm publish --otp "$otp" else npm publish fi # Push git commits and tags git push && git push --tags echo "Release completed successfully."