.PHONY: publish

# Publish with custom version
publish:
	@if [ -z "$(VERSION)" ]; then \
		echo "❌ Error: VERSION is required"; \
		echo "Usage: make publish VERSION=x.y.z"; \
		exit 1; \
	fi
	@echo "📦 Publishing version $(VERSION)..."
	@echo "1️⃣  Running type check..."
	@pnpm run type-check
	@echo "3️⃣  Updating version to $(VERSION)..."
	@pnpm version $(VERSION) --no-git-tag-version
	@echo "4️⃣  Building project..."
	@pnpm run build
	@echo "5️⃣  Publishing to npm..."
	@pnpm publish --access public --no-git-checks
	@echo "6️⃣  Committing version change..."
	@git add .
	@git commit -m "chore: bump version to $(VERSION)"
	@git tag -a "v$(VERSION)" -m "Release v$(VERSION)"
	@echo "✅ Published version $(VERSION) successfully!"
	@git push && git push --tags
