Skip to content

Instantly share code, notes, and snippets.

@hugosolar
Last active March 31, 2020 22:08
Show Gist options
  • Save hugosolar/5f06bd306ab955bf151dfa8e82d24e0b to your computer and use it in GitHub Desktop.
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
#!/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 .
@TimidRobot
Copy link

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

@TimidRobot
Copy link

I use 4 spaces instead of 2 spaces for Bash

@TimidRobot
Copy link

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