Skip to content

Commit

Permalink
Update Release Script
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezp committed Jan 11, 2023
1 parent 7285b32 commit a6ad06c
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions build_release.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
# Note: Keep trailing slash to copy contents of dir, but not dir itself
WORDPRESS_GIT_SRC_PATH="."
DESTINATION_PATH="../onesignal-free-web-push-notifications/trunk/"
RELEASE_ARCHIVE_FILENAME="onesignal-free-web-push-notifications.zip"

# Prevent accidental rm -rf issues if running as root
if (( $EUID == 0 )); then
if (( EUID == 0 )); then
echo "Please do not run this script as root for removing directory safety reasons."
exit
exit 1
fi

# Using exclude .* excludes dot files and dot directories like .git, .vscode
if [[ $DESTINATION_PATH != *onesignal-free-web-push-notifications/trunk/ ]]; then
echo "Script was going to remove ${DESTINATION_PATH}, but quitting because destination path unexpectedly does not end in ...onesignal-free-web-push-notifications/trunk/. Exiting to prevent removing unexpected directory."
exit
exit 1
fi

echo "Building Release Version of OneSignal WordPress Plugin"
echo "──────────────────────────────────────────────────────"
echo ""

echo "Removing destination folder '${DESTINATION_PATH}'."
rm -rf $DESTINATION_PATH

echo "Creating new empty destination folder '${DESTINATION_PATH}'."
mkdir -p $DESTINATION_PATH

echo "Copying contents of source directory '${WORDPRESS_GIT_SRC_PATH}' to destination directory '${DESTINATION_PATH}'."
rsync --archive --exclude=".*" --exclude="build_release.sh" --exclude="*.zip" --exclude="onesignal-free-web-push-notifications" $WORDPRESS_GIT_SRC_PATH $DESTINATION_PATH
# The --delete option remove files from destination that are not present in source
exclude_options=(
"--exclude=.git/"
"--exclude=.env"
"--exclude=.gitignore"
"--exclude=.github"
"--exclude=.vscode/"
"--exclude=build_release.sh"
"--exclude=*.zip"
"--exclude=onesignal-free-web-push-notifications"
"--exclude=CONTRIBUTING.md"
"--exclude=LICENSE"
"--exclude=docker*"
"--exclude=PluginDevDockerUsage.md"
"--exclude=README.md"
"--exclude=index.php"
"--exclude=views/css/*.scss"
"--exclude=views/css/callout.css"
"--exclude=views/css/link.css"
"--exclude=views/css/link.css"
"--exclude=views/css/semantic-ui"
)
rsync --archive --delete "${exclude_options[@]}" $WORDPRESS_GIT_SRC_PATH/ $DESTINATION_PATH

echo "Creating archive of release contents as '${RELEASE_ARCHIVE_FILENAME}' in source directory '${WORDPRESS_GIT_SRC_PATH}'."
last_dir=$(pwd)
cd ${WORDPRESS_GIT_SRC_PATH}
cd $WORDPRESS_GIT_SRC_PATH
zip -qr -x ".*" -x="build_release.sh" -x="*.zip" -x="onesignal-free-web-push-notifications" ${RELEASE_ARCHIVE_FILENAME} ./*
cd $last_dir

rm ../onesignal-free-web-push-notifications/trunk/README.md
rm ../onesignal-free-web-push-notifications/trunk/index.php
rm ../onesignal-free-web-push-notifications/trunk/views/css/*.scss
rm ../onesignal-free-web-push-notifications/trunk/views/css/callout.css
rm ../onesignal-free-web-push-notifications/trunk/views/css/link.css
rm -r ../onesignal-free-web-push-notifications/trunk/views/css/semantic-ui
cd -

0 comments on commit a6ad06c

Please sign in to comment.