homebrew-gitea/bump_version.sh
Alexey 〒erentyev 939e53988f Update gitea and change bump_script to save comments (#145)
as title

Co-authored-by: Alexey Terentyev <axifnx@gmail.com>
Reviewed-on: gitea/homebrew-gitea#145
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Co-committed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
2021-10-13 01:54:46 +08:00

32 lines
1.0 KiB
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 darwin-arm64";;
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}"
if [ "$os" != "linux-386" -a "$os" != "linux-arm64" ]; then
sha256_file="${sha256_file}.xz"
fi
sha256_file="${sha256_file}.sha256"
sha256=$(curl -sL "${file_url}/${sha256_file}" | awk '{print$1}')
sed -r "s/^(\s+when \"${os}\" then).*\"(.*)$/\1 \"${sha256}\"\2/" -i "${file}"
done
sed -r "s/^(\s+version).*/\1 \"${version}\"/" -i "${file}"
done