From 07e693cc853163d7a64011e826d81cc4f1e002f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Fri, 23 Nov 2018 16:10:55 +0100 Subject: [PATCH] =?UTF-8?q?asciiblaster-cordoba/release.sh:=20added=20to?= =?UTF-8?q?=20automate=20GitHub=20standalone=20Apache=20C=C3=B3rdoba=20And?= =?UTF-8?q?roid=20app=20releases.=20asciiblaster-cordoba/releases/:=20repl?= =?UTF-8?q?aced=20symlink=20with=20directory.=20.gitignore:=20ignore=20asc?= =?UTF-8?q?iiblaster-cordoba/releases/*.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + asciiblaster-cordoba/release.sh | 79 +++++++++++++++++++++++++++++++++ asciiblaster-cordoba/releases | 1 - 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100755 asciiblaster-cordoba/release.sh delete mode 120000 asciiblaster-cordoba/releases diff --git a/.gitignore b/.gitignore index 86beef4..0557dcb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ asciiblaster-cordoba/node_modules asciiblaster-cordoba/platforms/android/.gradle asciiblaster-cordoba/platforms/android/app/build asciiblaster-cordoba/platforms/android/CordovaLib/build +asciiblaster-cordoba/releases/* asciiblaster-nw/releases/* diff --git a/asciiblaster-cordoba/release.sh b/asciiblaster-cordoba/release.sh new file mode 100755 index 0000000..7e2a3bb --- /dev/null +++ b/asciiblaster-cordoba/release.sh @@ -0,0 +1,79 @@ +#!/bin/sh +# + +CORDOBA_PLATFORMS="android"; +PACKAGE_NAME="asciiblaster-cordoba"; +RELEASE_DEPS_CMD="cordova cp"; +RELEASE_DEPS_ENV="ANDROID_HOME JAVA_HOME"; +RELEASES_DNAME_DEST="releases"; +RELEASES_DNAME_SRC="platforms/%CORDOBA_PLATFORM%/app/build/outputs/apk"; + +msgf() { + local _fmt="${1}"; shift; + printf "%s >>> ${_fmt}\n" "$(date +"%d-%^b-%Y %H:%M:%S")" "${@}"; +}; + +subst() { + local _string="${1}" _search="${2}" _replace="${3}" _string_=""; + _string_="${_string%${_search}*}"; + _string_="${_string_}${_replace}" + _string_="${_string_}${_string#*${_search}}"; + echo "${_string_}"; +}; + +release() { + local _platform="${1}" _vflag="${2}" _release_dname_src="" _release_type="" _release_version=""; + + _release_dname_src="$(subst "${RELEASES_DNAME_SRC}" "%CORDOBA_PLATFORM%" "${_platform}")"; + _release_version="$(sed -n '/^\s*"version":/s/^.*:\s*"\([0-9.]\+\)",\?\s*$/\1/p' package.json)"; + for _release_type in debug release; do + cordova build "--${_release_type}" --device "${_platform}"; + cp -a "$(find "${_release_dname_src}/${_release_type}" -name \*.apk)" \ + "${RELEASES_DNAME_DEST}/${PACKAGE_NAME}-${_release_type}-${_release_version}.apk"; + done; +}; + +usage() { + echo "usage: ${0} [-h] [-v] [platform...]" >&2; + echo " -h.........: show this screen" >&2; + echo " -v.........: be verbose" >&2; + echo " platform...: one of: \`${CORDOBA_PLATFORMS}'" >&2; +}; + +main() { + local _cmd="" _opt="" _platform="" _platforms="" _vflag=0 _vname=""; + while getopts hv _opt; do + case "${_opt}" in + h) usage; exit 0; ;; + v) _vflag=1; ;; + *) usage; exit 1; ;; + esac; done; + shift $((${OPTIND}-1)); + for _cmd in ${RELEASE_DEPS_CMD}; do + if ! which "${_cmd}" >/dev/null; then + echo "error: missing prerequisite command \`${_cmd}'"; + exit 1; + fi; + done; + for _vname in ${RELEASE_DEPS_ENV}; do + if [ -z "$(eval echo \"\${_vname}\")" ]; then + echo "error: missing prerequisite environment variable \`${_vname}'"; + exit 1; + fi; + done; + _platforms="${@}"; mkdir -p "${RELEASES_DNAME_DEST}"; + for _platform in ${_platforms:-${CORDOBA_PLATFORMS}}; do + msgf "Building ${_platform} release..."; + if [ "${_vflag:-0}" -eq 0 ]; then + release "${_platform}" "${_vflag}" >/dev/null; + else + release "${_platform}" "${_vflag}"; + fi; + msgf "Built ${_platform} release."; + done; +}; + +set -o errexit -o noglob; +main "${@}"; + +# vim:foldmethod=marker sw=8 ts=8 tw=120 diff --git a/asciiblaster-cordoba/releases b/asciiblaster-cordoba/releases deleted file mode 120000 index 481bb70..0000000 --- a/asciiblaster-cordoba/releases +++ /dev/null @@ -1 +0,0 @@ -platforms/android/app/build/outputs/apk \ No newline at end of file