mas/script/brew_core_update
Ben Chatelain 401c82b28d
🩹 Use tag name to calculate PRE_RELEASE value
The MAS_VERSION env var isn't made available to the pre_release step
2024-11-17 11:35:31 -07:00

59 lines
1.1 KiB
Bash
Executable file

#!/bin/bash -ex
#
# script/brew_core_update
# mas
#
# Updates mas Homebrew core formula:
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb
#
# brew bump-formula-pr --help
#
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
if ! cd -- "${mas_dir}"; then
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
exit 1
fi
function usage {
echo 'Usage: brew_core_update [-d]' >&2
echo ' -d option enables dry run mode' >&2
exit 1
}
# Max 1 argument
if [[ "${#}" -gt 1 ]]; then
usage
fi
dry_run=
# Detect presence of `-d` dry run option
while getopts 'd' o; do
case "${o}" in
d)
dry_run=--dry-run
;;
*)
usage
;;
esac
done
shift "$((OPTIND - 1))"
version_tag="v$(script/version)"
revision="$(git rev-parse "${version_tag}")"
echo "==> 🧪 Updating mas homebrew-core formula to version tag ${version_tag} @ revision ${revision}"
brew bump-formula-pr \
--tag "${version_tag}" \
--revision "${revision}" \
--fork-org mas-cli \
--no-browse \
--online \
--strict \
--verbose \
${dry_run} \
mas