2019-04-06 21:38:29 +00:00
|
|
|
#!/bin/bash
|
2019-03-31 22:50:25 +00:00
|
|
|
#
|
2019-04-01 03:05:13 +00:00
|
|
|
# script/brew_formula_update
|
2019-03-31 22:50:25 +00:00
|
|
|
# mas
|
|
|
|
#
|
|
|
|
# Updates mas Homebrew core formula:
|
|
|
|
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb
|
|
|
|
#
|
2019-04-01 04:00:29 +00:00
|
|
|
# brew bump-formula-pr --help
|
|
|
|
#
|
2019-03-31 22:50:25 +00:00
|
|
|
|
2019-03-31 23:34:33 +00:00
|
|
|
BREW_CORE_PATH="$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula"
|
2019-03-31 22:50:25 +00:00
|
|
|
|
|
|
|
function usage {
|
|
|
|
echo "Usage: brew_formula_bump [v1.0] [sha1_hash]"
|
|
|
|
echo "- version will be inferred using version script if not provided"
|
2020-05-25 05:24:14 +00:00
|
|
|
echo "- sha will be inferred from the current commit if not provided"
|
2019-03-31 22:50:25 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# arg 1 - version tag
|
|
|
|
if test -n "$1"; then
|
|
|
|
VERSION="$1"
|
|
|
|
else
|
|
|
|
VERSION="v$(script/version)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# arg 2 - revision (commit hash)
|
|
|
|
if test -n "$2"; then
|
|
|
|
REVISION="$2"
|
|
|
|
else
|
|
|
|
REVISION=$(git rev-parse HEAD)
|
|
|
|
fi
|
|
|
|
|
2020-05-25 05:24:14 +00:00
|
|
|
# Purge the Carthage cache to avoid this error from Homebrew sandboxing:
|
|
|
|
# A shell task (/usr/bin/env git checkout --quiet --force 0.15.0 (launched in /Users/ben/Library/Caches/org.carthage.CarthageKit/dependencies/Commandant)) failed with exit code 128:
|
|
|
|
# fatal: Unable to create '/Users/ben/Library/Caches/org.carthage.CarthageKit/dependencies/Commandant/./index.lock': Operation not permitted
|
|
|
|
rm -rf ~/Library/Caches/org.carthage.CarthageKit
|
|
|
|
|
2019-03-31 23:34:33 +00:00
|
|
|
echo "Checking to see if this update can be a simple bump."
|
2019-04-01 04:00:29 +00:00
|
|
|
diff "Homebrew/mas.rb" "$BREW_CORE_PATH/mas.rb"
|
|
|
|
|
|
|
|
# diff exit status
|
|
|
|
status=$?
|
|
|
|
formula_revisions=0
|
|
|
|
if test $status -ne 0; then
|
2019-03-31 23:34:33 +00:00
|
|
|
echo "There are changes in the local formula (Homebrew/mas.rb) that haven't been released yet."
|
2019-04-01 04:00:29 +00:00
|
|
|
#exit $status
|
|
|
|
formula_revisions=1
|
2019-03-31 23:34:33 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-31 22:50:25 +00:00
|
|
|
echo "==> 🧪 Updating homebrew-core formula mas ($VERSION, $REVISION)"
|
|
|
|
|
|
|
|
echo "Validating formula"
|
|
|
|
brew bump-formula-pr \
|
|
|
|
--tag="$VERSION" \
|
|
|
|
--revision="$REVISION" \
|
|
|
|
--strict \
|
|
|
|
mas
|
|
|
|
|
2019-04-01 04:00:29 +00:00
|
|
|
# brew exit status
|
|
|
|
status=$?
|
|
|
|
if test $status -ne 0; then
|
2019-04-06 21:38:29 +00:00
|
|
|
echo "Formula did not validate using 'brew bump-formula-pr'"
|
2019-04-01 04:00:29 +00:00
|
|
|
exit $status
|
|
|
|
fi
|
|
|
|
|
2019-04-06 21:38:29 +00:00
|
|
|
pushd "$BREW_CORE_PATH" || exit 2
|
2019-03-31 22:50:25 +00:00
|
|
|
|
|
|
|
echo "Updating formula"
|
2019-04-01 04:00:29 +00:00
|
|
|
if test $formula_revisions -eq 1; then
|
2019-04-06 21:38:29 +00:00
|
|
|
# Options to
|
2019-04-01 04:00:29 +00:00
|
|
|
dry_run="--dry-run --write"
|
|
|
|
fi
|
|
|
|
|
2019-03-31 22:50:25 +00:00
|
|
|
brew bump-formula-pr \
|
|
|
|
--tag="$VERSION" \
|
|
|
|
--revision="$REVISION" \
|
|
|
|
--strict \
|
|
|
|
--verbose \
|
2019-04-06 21:38:29 +00:00
|
|
|
"$dry_run" \
|
2019-03-31 22:50:25 +00:00
|
|
|
mas
|