From 18342308b2cc81db5cd4552341d28b1e7867d78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Fri, 23 Nov 2018 21:05:45 +0100 Subject: [PATCH] assets/shell/bump-version.sh: added to repository. --- assets/shell/bump-version.sh | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 assets/shell/bump-version.sh diff --git a/assets/shell/bump-version.sh b/assets/shell/bump-version.sh new file mode 100755 index 0000000..73ef94a --- /dev/null +++ b/assets/shell/bump-version.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# + +RELEASE_DEPS="rsync sed"; + +rc() { + local _cmd="${1}"; shift; + printf "%s >>> %s %s\n" "$(date +"%d-%^b-%Y %H:%M:%S")" "${_cmd}" "${*}"; + "${_cmd}" "${@}"; +}; + +usage() { + echo "usage: ${0} [-h] old_version new_version" >&2; + echo " -h.........: show this screen" >&2; +}; + +main() { + local _opt="" _version_new="" _version_old=""; + while getopts hv _opt; do + case "${_opt}" in + h) usage; exit 0; ;; + *) usage; exit 1; ;; + esac; done; + shift $((${OPTIND}-1)); + if [ -z "${1}" ]; then + echo "error: empty or missing old version number argument" >&2; usage; exit 1; + elif [ -z "${2}" ]; then + echo "error: empty or missing new version number argument" >&2; usage; exit 1; + else + _version_old="${1}"; _version_new="${2}"; + fi; + for _cmd in ${RELEASE_DEPS_CMD}; do + if ! which "${_cmd}" >/dev/null; then + echo "error: missing prerequisite command \`${_cmd}'"; + exit 1; + fi; + done; + rc sed -i"" '/"version":/s/\("version":\s*\)"'"${_version_old}"'"/\1"'"${_version_new}"'"/' \ + asciiblaster-cordoba/package.json \ + asciiblaster-cordoba/package-lock.json \ + asciiblaster-nw/package.json \ + asciiblaster-nw/package-lock.json; + rc sed -i"" '/version="/s/\(version=\)"'"${_version_old}"'"/\1"'"${_version_new}"'"/' \ + asciiblaster-cordoba/config.xml; + rc sed -i"" '/[^<]\+ v/s/\(<title>[^<]\+ v\)'"${_version_old}"'\(<\)/\1'"${_version_new}"'\2/' \ + index.html; + rc rsync -aiLPv --delete \ + asciiblaster-cordoba/www/ \ + asciiblaster-cordoba/platforms/android/app/src/main/assets/www/; + rc git add asciiblaster-cordoba/platforms/android/app/src/main/assets/www; + rc git commit -avm "Bump to v${_version_new}."; +}; + +set -o errexit -o noglob; +main "${@}"; + +# vim:foldmethod=marker sw=8 ts=8 tw=120