Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 557ff54b2b435e5f1e789c6a8a4e1bebf2d7deb6 78 lines 2.2 kB view raw
1#!/bin/bash 2 3# Script to publish packages to @roostorg npm registry 4# Make sure you're logged into npm with proper permissions 5 6set -e 7 8echo "🚀 Publishing packages to @roostorg scope..." 9 10# Check if user is logged in to npm 11if ! npm whoami > /dev/null 2>&1; then 12 echo "❌ Not logged in to npm. Please run:" 13 echo " npm login" 14 echo " Use your npm username and password/token" 15 exit 1 16fi 17 18echo "✅ Logged in to npm as: $(npm whoami)" 19 20# Check if OTP is provided 21if [ -z "$NPM_OTP" ]; then 22 echo "⚠️ Two-factor authentication is enabled. Please provide OTP:" 23 echo " export NPM_OTP=<your-otp-code>" 24 echo " ./scripts/publish-packages.sh" 25 echo "" 26 echo "Or run with OTP directly:" 27 echo " NPM_OTP=<your-otp-code> ./scripts/publish-packages.sh" 28 exit 1 29fi 30 31# Function to check if package version exists 32check_version_exists() { 33 local package_name=$1 34 local version=$2 35 36 if npm view "$package_name@$version" version >/dev/null 2>&1; then 37 echo "⚠️ Version $version of $package_name already exists on npm" 38 return 0 39 else 40 echo "✅ Version $version of $package_name is available for publishing" 41 return 1 42 fi 43} 44 45# Function to publish package if version doesn't exist 46publish_if_needed() { 47 local package_dir=$1 48 local package_name=$2 49 50 cd "$package_dir" 51 52 # Get current version from package.json 53 local version=$(node -p "require('./package.json').version") 54 55 echo "📦 Checking $package_name@$version..." 56 57 if check_version_exists "$package_name" "$version"; then 58 echo "⏭️ Skipping $package_name@$version (already published)" 59 cd .. 60 return 61 fi 62 63 echo "📦 Publishing $package_name@$version..." 64 npm install 65 npm run build 66 npm publish --otp=$NPM_OTP 67 cd .. 68} 69 70# Publish packages 71publish_if_needed "types" "@roostorg/types" 72publish_if_needed "migrator" "@roostorg/db-migrator" 73 74echo "✅ All packages published successfully!" 75echo "" 76echo "Next steps:" 77echo "1. Run 'npm install' in server/ and client/ directories to update dependencies" 78echo "2. The GitHub Action will automatically publish future changes when you push to main/OSS branches"