Last active
March 31, 2020 22:08
-
-
Save hugosolar/5f06bd306ab955bf151dfa8e82d24e0b to your computer and use it in GitHub Desktop.
This is a bash script to release new version of the current wp-theme-cc-chapter theme with all the needed dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script generates a release zip file from the WordPress theme of the CC Chapter websites | |
# useful for standaolone installs | |
set -o errexit | |
set -o errtrace | |
set -o nounset | |
trap '_es=${?}; | |
printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\""; | |
printf " exited with a status of ${_es}\n"; | |
exit ${_es}' ERR | |
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
echo "Check dependencies..." | |
#Check if git is installed | |
if hash git 2>/dev/null; then | |
echo ">> Git ok" | |
else | |
echo "[ERROR] Cannot find Git installed. Please install before proceed" 1>&2 | |
exit 1 | |
fi | |
#Check if node / npm is installed | |
if hash git 2>/dev/null; then | |
echo ">> Node / npm ok" | |
else | |
echo "[ERROR] Cannot find NodeJS installed. Please install before proceed" 1>&2 | |
exit 1 | |
fi | |
#Check if composer is installed | |
if hash git 2>/dev/null; then | |
echo ">> Composer ok" | |
else | |
echo "[ERROR] Cannot find NodeJS installed. Please install before proceed" 1>&2 | |
exit 1 | |
fi | |
mkdir -p release | |
cd release | |
mkdir -p themes | |
cd themes | |
echo "Cloning repository ... " | |
git clone git@github.com:creativecommons/wp-theme-cc-chapter.git | |
cd wp-theme-cc-chapter | |
composer install | |
cd "${BASE_DIR}" | |
cp queulat.php release/mu-plugins/ | |
cd release | |
zip -r wp-theme-cc-chapter.zip . | |
Echo errors to stdout and use a non-zero exit status. For example:
echo "[ERROR] Cannot find Git installed. Please install before proceed" 1>&2
exit 1
I use 4 spaces instead of 2 spaces for Bash
Whenever you mkdir
consider using -p
in case it already exists for some reason:
mkdir -p release
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like to start my bash scripts with: