Skip to content

Commit

Permalink
Merge pull request woocommerce#26407 from woocommerce/feature/build-zip
Browse files Browse the repository at this point in the history
Introduced script to generate a zip package
  • Loading branch information
Konamiman authored May 15, 2020
2 parents eab8920 + 32d2b79 commit 3d2927f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bin/build-zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

PLUGIN_SLUG="woocommerce"
PROJECT_PATH=$(pwd)
BUILD_PATH="${PROJECT_PATH}/build"
DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG"

echo "Generating build directory..."
rm -rf "$BUILD_PATH"
mkdir -p "$DEST_PATH"

echo "Installing PHP and JS dependencies..."
npm install
composer install || exit "$?"
echo "Running JS Build..."
npm run build || exit "$?"
echo "Cleaning up PHP dependencies..."
composer install --no-dev || exit "$?"

echo "Syncing files..."
rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded

echo "Restoring PHP dependencies..."
composer install || exit "$?"
npm run build || exit "$?"

echo "Generating zip file..."
cd "$BUILD_PATH" || exit
zip -q -r "${PLUGIN_SLUG}.zip" "$PLUGIN_SLUG/"
echo "$BUILD_PATH/${PLUGIN_SLUG}.zip file generated!"

echo "Build done!"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"build": "grunt && npm run makepot",
"build-watch": "grunt watch",
"build:zip": "./bin/build-zip.sh",
"lint:js": "eslint assets/js --ext=js",
"docker:up": "npm explore @woocommerce/e2e-environment -- npm run docker:up",
"docker:down": "npm explore @woocommerce/e2e-environment -- npm run docker:down",
Expand Down

0 comments on commit 3d2927f

Please sign in to comment.