Remove dependency on brew in scripts/release (#23)

Fix #22
This commit is contained in:
Denis Isidoro 2019-09-21 17:14:52 -03:00 committed by GitHub
parent 1a111a97d6
commit 62d64c2e03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,27 +4,55 @@ set -euo pipefail
export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
echo "git pull" command_exists () {
git pull type "$1" &> /dev/null
}
echoerr() {
echo "$@" 1>&2
}
sha256() {
if command_exists sha256sum; then
sha256sum
elif command_exists shasum; then
shasum -a 256
elif command_exists openssl; then
openssl dgst -sha256
else
echoerr "Unable to calculate sha256!"
exit 43
fi
}
header() {
echo "$*"
echo
}
header "git pull"
#git pull
version="$(grep VERSION "${SCRIPT_DIR}/navi" | grep -Eo '[0-9\.]+')" version="$(grep VERSION "${SCRIPT_DIR}/navi" | grep -Eo '[0-9\.]+')"
tag="v${version}" tag="v${version}"
tar="https://github.com/denisidoro/navi/archive/${tag}.tar.gz" tar="https://github.com/denisidoro/navi/archive/${tag}.tar.gz"
formula="/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/navi.rb" formula="/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/navi.rb"
echo "Attempting to release version ${tag}..." header "Attempting to release version ${tag}..."
read -p "Press enter to continue"
echo "git tag" header "git tag"
git tag -a "$tag" -m "$tag" #git tag -a "$tag" -m "$tag"
echo "git push" header "git push"
git push --follow-tags #git push --follow-tags
echo "rm formula" header "rm formula"
rm "$formula" || true rm "$formula" || true
echo "brew create" header "tar sha256"
brew create "$tar" sha="$(curl -sL "$tar" | sha256 | awk '{print $1}')"
echo "output" header "output"
grep "url" "$formula" -A1 echo " url \"${tar}\""
echo " sha256 \"${sha}\""