-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·85 lines (73 loc) · 2.92 KB
/
build.sh
File metadata and controls
executable file
·85 lines (73 loc) · 2.92 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
#!/bin/bash
#
# WebDecoy WordPress Plugin Build Script
#
# Creates a distributable ZIP file for the WordPress plugin
# that can be uploaded to a CDN or WordPress marketplace.
#
# Usage: ./build.sh [version]
# Example: ./build.sh 1.0.0
#
set -e
# Configuration
PLUGIN_SLUG="webdecoy"
VERSION="${1:-1.0.0}"
BUILD_DIR="./build"
DIST_DIR="./dist"
echo "Building WebDecoy WordPress Plugin v${VERSION}"
echo "================================================"
# Clean previous builds
echo "Cleaning previous builds..."
rm -rf "${BUILD_DIR}"
rm -rf "${DIST_DIR}"
mkdir -p "${BUILD_DIR}/${PLUGIN_SLUG}"
mkdir -p "${DIST_DIR}"
# Copy plugin files into build directory
echo "Copying plugin files..."
rsync -a --exclude='build' --exclude='dist' --exclude='build.sh' . "${BUILD_DIR}/${PLUGIN_SLUG}/"
# Update version in main plugin file
echo "Setting version to ${VERSION}..."
sed -i '' "s/Version: .*/Version: ${VERSION}/" "${BUILD_DIR}/${PLUGIN_SLUG}/webdecoy.php"
sed -i '' "s/define('WEBDECOY_VERSION', '.*');/define('WEBDECOY_VERSION', '${VERSION}');/" "${BUILD_DIR}/${PLUGIN_SLUG}/webdecoy.php"
# Install Composer dependencies (production only)
echo "Installing Composer dependencies..."
cd "${BUILD_DIR}/${PLUGIN_SLUG}/sdk"
if command -v composer &> /dev/null; then
composer install --no-dev --optimize-autoloader --no-interaction 2>/dev/null || {
echo "Composer install failed or no dependencies - continuing..."
}
fi
cd - > /dev/null
# Remove development files
echo "Cleaning development files..."
find "${BUILD_DIR}" -name ".git*" -exec rm -rf {} + 2>/dev/null || true
find "${BUILD_DIR}" -name ".DS_Store" -exec rm -f {} + 2>/dev/null || true
find "${BUILD_DIR}" -name "*.md" -not -name "README.md" -exec rm -f {} + 2>/dev/null || true
find "${BUILD_DIR}" -name "phpunit.xml*" -exec rm -f {} + 2>/dev/null || true
find "${BUILD_DIR}" -name "phpcs.xml*" -exec rm -f {} + 2>/dev/null || true
find "${BUILD_DIR}" -name ".phpcs*" -exec rm -f {} + 2>/dev/null || true
find "${BUILD_DIR}" -name "tests" -type d -exec rm -rf {} + 2>/dev/null || true
# Create ZIP file
echo "Creating ZIP archive..."
cd "${BUILD_DIR}"
zip -r "../${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip" "${PLUGIN_SLUG}" -x "*.DS_Store" -x "*__MACOSX*"
cd - > /dev/null
# Generate checksums
echo "Generating checksums..."
cd "${DIST_DIR}"
shasum -a 256 "${PLUGIN_SLUG}-${VERSION}.zip" > "${PLUGIN_SLUG}-${VERSION}.zip.sha256"
md5 -q "${PLUGIN_SLUG}-${VERSION}.zip" > "${PLUGIN_SLUG}-${VERSION}.zip.md5"
cd - > /dev/null
# Calculate file size
FILE_SIZE=$(ls -lh "${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip" | awk '{print $5}')
echo ""
echo "Build complete!"
echo "================================================"
echo "Output: ${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip"
echo "Size: ${FILE_SIZE}"
echo ""
echo "Checksums:"
cat "${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip.sha256"
echo "MD5: $(cat "${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip.md5")"
echo ""
echo "Upload to CDN or WordPress.org for distribution"