-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·121 lines (97 loc) · 3.03 KB
/
publish.sh
File metadata and controls
executable file
·121 lines (97 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Publish script for node-mac-recorder
# Usage: ./publish.sh <patch|minor|major> "commit message"
# Clean up development files before publishing
echo "🧹 Cleaning up development files..."
# Remove video files
echo " • Removing .mov and .mp4 files..."
find . -name "*.mov" -type f -delete 2>/dev/null
find . -name "*.mp4" -type f -delete 2>/dev/null
# Remove files containing specific keywords
echo " • Removing files containing test, debug, example, demo, sample..."
find . -type f -not -path "./node_modules/*" \( \
-name "*test*" -o \
-name "*debug*" -o \
-name "*example*" -o \
-name "*demo*" -o \
-name "*sample*" \
\) -delete 2>/dev/null
# Remove folders containing specific keywords
echo " • Removing folders containing test, debug, example, demo, sample..."
find . -type d -not -path "./node_modules/*" \( \
-name "*test*" -o \
-name "*debug*" -o \
-name "*example*" -o \
-name "*demo*" -o \
-name "*sample*" \
\) -exec rm -rf {} + 2>/dev/null
echo "✅ Cleanup completed"
echo ""
# Check if correct number of arguments provided
if [ $# -ne 2 ]; then
echo "❌ Usage: $0 <patch|minor|major> \"commit message\""
echo " Example: $0 patch \"Fix multi-display coordinate issues\""
exit 1
fi
VERSION_TYPE=$1
COMMIT_MESSAGE=$2
# Validate version type
if [[ "$VERSION_TYPE" != "patch" && "$VERSION_TYPE" != "minor" && "$VERSION_TYPE" != "major" ]]; then
echo "❌ Invalid version type: $VERSION_TYPE"
echo " Must be one of: patch, minor, major"
exit 1
fi
# Check if we're in a git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "❌ Not in a git repository"
exit 1
fi
# Check if there are uncommitted changes
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "📁 Adding all changes to git..."
git add .
if [ $? -ne 0 ]; then
echo "❌ Failed to add files to git"
exit 1
fi
echo "📝 Committing changes..."
git commit -m "$COMMIT_MESSAGE"
if [ $? -ne 0 ]; then
echo "❌ Failed to commit changes"
exit 1
fi
echo "✅ Changes committed successfully"
else
echo "ℹ️ No uncommitted changes found"
fi
# Bump version
echo "📦 Bumping $VERSION_TYPE version..."
npm version $VERSION_TYPE
if [ $? -ne 0 ]; then
echo "❌ Failed to bump version"
exit 1
fi
NEW_VERSION=$(node -p "require('./package.json').version")
echo "✅ Version bumped to: $NEW_VERSION"
# Push to git
echo "🚀 Pushing to git..."
git push origin HEAD
if [ $? -ne 0 ]; then
echo "❌ Failed to push to git"
exit 1
fi
echo "✅ Pushed to git successfully"
# Publish to npm
echo "📤 Publishing to npm..."
npm publish
if [ $? -ne 0 ]; then
echo "❌ Failed to publish to npm"
exit 1
fi
echo "🎉 Successfully published version $NEW_VERSION to npm!"
echo ""
echo "📋 Summary:"
echo " • Committed: '$COMMIT_MESSAGE'"
echo " • Version: $NEW_VERSION ($VERSION_TYPE bump)"
echo " • Git: Pushed to remote"
echo " • NPM: Published successfully"