Skip to content

Commit 6ec760c

Browse files
Shukriclaude
authored andcommitted
ci: add pre-push hook to build plugin ZIP locally before every push
Run once to activate: git config core.hooksPath .githooks ZIP lands in dist/devpulse-{version}.zip (gitignored), ready to upload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7893dfa commit 6ec760c

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

.githooks/pre-push

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
# Build a clean plugin ZIP before every push.
3+
# The ZIP lands in dist/ (gitignored) so you can upload it directly to WordPress.
4+
5+
set -e
6+
7+
PLUGIN_DIR="$(cd "$(dirname "$0")/.." && pwd)"
8+
VERSION=$(grep -m1 "^ \* Version:" "$PLUGIN_DIR/devpulse.php" | awk '{print $3}')
9+
ZIP_NAME="devpulse-${VERSION}.zip"
10+
DIST_DIR="$PLUGIN_DIR/dist"
11+
12+
echo "📦 Building $ZIP_NAME..."
13+
14+
# Clean previous build
15+
rm -rf "$DIST_DIR"
16+
mkdir -p "$DIST_DIR/devpulse"
17+
18+
# Copy plugin files, excluding everything that shouldn't ship
19+
rsync -r \
20+
--exclude='.git' \
21+
--exclude='.github' \
22+
--exclude='.githooks' \
23+
--exclude='.gitattributes' \
24+
--exclude='.gitignore' \
25+
--exclude='composer.json' \
26+
--exclude='composer.lock' \
27+
--exclude='vendor' \
28+
--exclude='README.md' \
29+
--exclude='dist' \
30+
--exclude='*.zip' \
31+
"$PLUGIN_DIR/" "$DIST_DIR/devpulse/"
32+
33+
# Create the ZIP
34+
cd "$DIST_DIR"
35+
zip -r "$ZIP_NAME" devpulse/ -x "*.DS_Store"
36+
rm -rf devpulse/
37+
38+
echo "✅ dist/$ZIP_NAME is ready to upload"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
*.zip
3+
dist/

0 commit comments

Comments
 (0)