-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·105 lines (89 loc) · 3.13 KB
/
release.sh
File metadata and controls
executable file
·105 lines (89 loc) · 3.13 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
#!/bin/bash
# CR Chatbot Release Script
# This script prepares the project for a new release
set -e
echo "🚀 CR Chatbot Release Preparation"
echo "================================="
# Check if version is provided
if [ -z "$1" ]; then
echo "❌ Error: Please provide a version number"
echo "Usage: ./release.sh v1.0.0"
exit 1
fi
VERSION=$1
echo "📦 Preparing release: $VERSION"
# Validate version format (allow alpha, beta, rc suffixes)
if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo "❌ Error: Version must be in format v1.0.0 or v1.0.0-alpha"
exit 1
fi
# Check if we're in a git repository
if [ ! -d ".git" ]; then
echo "❌ Error: Not in a git repository"
exit 1
fi
# Check if working directory is clean
if [ -n "$(git status --porcelain)" ]; then
echo "❌ Error: Working directory is not clean"
echo "Please commit or stash your changes first"
git status --short
exit 1
fi
# Update package.json version
echo "📝 Updating package.json version..."
if [ -f "package.json" ]; then
# Remove 'v' prefix for package.json
PACKAGE_VERSION=${VERSION#v}
sed -i.bak "s/\"version\": \".*\"/\"version\": \"$PACKAGE_VERSION\"/" package.json
rm package.json.bak
echo "✅ Updated package.json to version $PACKAGE_VERSION"
else
echo "⚠️ Warning: package.json not found"
fi
# Update README badges if needed
echo "📝 Updating README badges..."
if [ -f "README.md" ]; then
sed -i.bak "s/GitHub%20Release-v[0-9]\+\.[0-9]\+\.[0-9]\+/GitHub%20Release-$VERSION/" README.md
rm README.md.bak 2>/dev/null || true
fi
# Run basic checks
echo "🔍 Running pre-release checks..."
# Check if main files exist
REQUIRED_FILES=("cr-chatbot/index.html" "cr-chatbot/script.js" "cr-chatbot/styles.css" "README.md" "LICENSE")
for file in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$file" ]; then
echo "❌ Error: Required file $file is missing"
exit 1
fi
done
echo "✅ All required files present"
# Check for JavaScript syntax errors (basic check)
echo "🔍 Checking JavaScript syntax..."
if command -v node >/dev/null 2>&1; then
node -c cr-chatbot/script.js
echo "✅ JavaScript syntax check passed"
else
echo "⚠️ Skipping JavaScript check (Node.js not installed)"
fi
# Check for HTML validation (basic check)
echo "🔍 Checking HTML structure..."
if command -v tidy >/dev/null 2>&1; then
tidy -q -e cr-chatbot/index.html || echo "⚠️ HTML validation warnings (non-critical)"
else
echo "⚠️ Skipping HTML check (tidy not installed)"
fi
# Create git tag
echo "🏷️ Creating git tag: $VERSION"
git add package.json README.md 2>/dev/null || true
git commit -m "chore: bump version to $VERSION" 2>/dev/null || echo "No changes to commit"
git tag -a "$VERSION" -m "Release $VERSION"
echo ""
echo "✅ Release preparation complete!"
echo ""
echo "📋 Next steps:"
echo "1. Push the changes: git push origin main --tags"
echo "2. Create a GitHub release at: https://github.com/3eekeeper/cr-chatbot/releases/new"
echo "3. Upload the release assets if needed"
echo "4. Update the GitHub Pages deployment"
echo ""
echo "🎉 Release $VERSION is ready!"