homebrew-gitea/bump_version.sh
markkrj 10c0dc82d8 Fix homebrew tap by removing head and shipping compiled binaries (#136)
fixes #135

This fix Homebrew tap by removing the head method and shipping only pre-compiled binaries, as you guys already ship binaries for most (all?) supported platforms.

Also, for gitea.rb and tea.rb, I removed the curl for fetching files checksum, because for every install, it runs `curl` 5 times, slowing the install. So, I created a script to bump versions to latest and fix sha256 checksum in the formula files.

I created also an gitea-head and tea-head formulae to download latest pre-compiled binaries for head, and here we are fetching checksum by `curl`, as I imagine, it is not common/recommended scenario.

IMO, this is the best possible approach for shipping binaries from a custom tap.

Co-authored-by: Marcos de Oliveira <markinholiveira@gmail.com>
Reviewed-on: gitea/homebrew-gitea#136
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: markkrj <markkrj@noreply.gitea.io>
Co-committed-by: markkrj <markkrj@noreply.gitea.io>
2021-06-30 02:00:18 +08:00

28 lines
877 B
Bash
Executable File

#!/bin/sh
binaries="tea gitea"
for bin in ${binaries};do
file="${bin}.rb"
case "$bin" in
tea)
git_url="https://gitea.com/gitea/tea"
supported_os="linux-386 linux-amd64 linux-arm64 darwin-amd64";;
gitea)
git_url="https://github.com/go-gitea/gitea"
supported_os="linux-386 linux-amd64 linux-arm64 darwin-10.12-amd64 darwin-10.12-arm64";;
*)
>&2 echo "Error: unrecognized binary ($bin)"
exit 1;;
esac
latest=$(curl -sL -o /dev/null -w %{url_effective} "${git_url}/releases/latest")
version="${latest##*/v}"
file_url="https://dl.gitea.io/${bin}/${version}"
for os in ${supported_os}; do
sha256_file="${bin}-${version}-${os}.xz.sha256"
sha256=$(curl -sL "${file_url}/${sha256_file}" | awk '{print$1}')
sed -r "s/^(\s+when \"${os}\" then).*/\1 \"${sha256}\"/" -i "${file}"
done
sed -r "s/^(\s+version).*/\1 \"${version}\"/" -i "${file}"
done