Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash script for zipping plugin #25

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#Enter your directory below where plugin is located or place the script in the plugin directory
PLUGIN_DIR="."

ZIP_FILE="$PLUGIN_DIR/woocommerce-plugin.zip"

EXCLUDE_LIST=(
"$PLUGIN_DIR/.git/*"
"$PLUGIN_DIR/.plugin.sh"
)


if [ -f "$ZIP_FILE" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be better to add a prompt asking the user whether to overwrite the existing file ?

echo "Regular ZIP file exists."
else
echo "ZIP file does not exist."
fi

EXCLUDE_PARAMS=()
for item in "${EXCLUDE_LIST[@]}"; do
EXCLUDE_PARAMS+=("-x" "$item")
done

zip -r "$ZIP_FILE" "$PLUGIN_DIR" "${EXCLUDE_PARAMS[@]}"

echo "zip file created: $ZIP_FILE"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be better to check the exit status of the zip command as if there’s an issue with file permissions, disk space, or other problems, the script will continue and may report success even if the ZIP creation failed.

Binary file added woocommerce-plugin.zip
Binary file not shown.