This repository has been archived on 2024-05-06. You can view files and clone it, but cannot push or open issues or pull requests.
package/upgpkg.sh
2020-11-22 02:17:02 +01:00

53 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/sh
commit_message=""
function get_latest_version()
{
repo=$1
prefix="v"
[ -n "$2" ] && prefix="$2-v"
releases_json=$(curl -s "https://git.serguzim.me/api/v1/repos/emgauwa/$repo/releases")
[ $? -ne 0 ] && echo "v0.0.0" && exit
tags=$(echo $releases_json | jq -r ".[] | select(.tag_name | test(\"$prefix*\")).tag_name")
latest_version="0.0.0"
for tag in $tags; do
version=$(echo $tag | sed "s/^$prefix//")
[ $(vercmp $version $latest_version) -gt 0 ] && latest_version=$version
done
echo $latest_version
}
function upgrade_package()
{
cd $1
current_version=$(grep -Po "pkgver=\K.*$" PKGBUILD)
latest_version=$(get_latest_version $2)
sed -i "s/pkgver=.*$/pkgver=$latest_version/" PKGBUILD
sed -i "s/pkgrel=.*$/pkgrel=1/" PKGBUILD # reset pkgrel
updpkgsums
if [ "$current_version" != "$latest_version" ]
then
commit_message="$commit_message Upgrade $1 to v$latest_version\n"
git add PKGBUILD
fi
cd ..
}
upgrade_package "controller" "controller"
upgrade_package "controller-testing" "controller testing"
upgrade_package "core" "core"
upgrade_package "core-testing" "core testing"
upgrade_package "webapp" "client"
printf "$commit_message" | git commit -F -
git show -s