mas/script/brew_tap_update
2024-07-31 21:04:54 -06:00

69 lines
1.4 KiB
Bash
Executable file

#!/bin/bash -ex
#
# script/brew_tap_update
# mas
#
# Updates mas custom tap formula:
# https://github.com/mas-cli/homebrew-tap/blob/main/Formula/mas.rb
#
MAS_TAP_PATH="$(brew --repository mas-cli/tap)"
MAS_TAP_FORMULA_FILE="${MAS_TAP_PATH}/Formula/mas.rb"
PROJECT_PATH="$(git rev-parse --show-toplevel)"
LOCAL_TAP_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas-tap.rb"
function usage {
echo "Usage: brew_tap_update [-d] v0.0 [sha1_hash]"
echo " -d option enables dry run mode"
echo " version will be inferred using version script if not provided"
echo " sha will be inferred from the current commit if not provided"
exit 1
}
# Max 3 arguments
if [[ $# -gt 3 ]]; then
usage 1>&2
fi
echo=''
# Detect presence of `-d` dry run option
while getopts "d" o; do
case "${o}" in
d)
echo='echo (DRY-RUN):'
;;
*)
usage 1>&2
;;
esac
done
# DRY_RUN environment variable
# shellcheck disable=SC2153
if [[ $DRY_RUN == 'true' ]]; then
echo='echo (DRY-RUN):'
fi
# arg 1 - version tag
if [[ -n "${1}" ]]; then
MAS_VERSION="${1}"
else
MAS_VERSION="v$(script/version)"
fi
echo "MAS_VERSION: ${MAS_VERSION}"
# arg 2 - revision (commit hash)
if [[ -n "${2}" ]]; then
REVISION="${2}"
else
# Derive revision from version. Fails if MAS_VERSION is not a tag.
REVISION=$(git rev-parse "${MAS_VERSION}")
fi
echo "REVISION: ${REVISION}"
# Build in mas project
script/bottle