Created
August 26, 2020 18:15
-
-
Save inverse/8c844d2870c5595ad1b205753831515c to your computer and use it in GitHub Desktop.
Psalm updater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PACKAGE=psalm | |
REPO=vimeo/$PACKAGE | |
if [ "$#" -ne 1 ] | |
then | |
echo "Trying ro resolve latest..." | |
VERSION=$(curl --silent "https://api.github.com/repos/${REPO}/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")') | |
else | |
VERSION=$1 | |
fi | |
read -r -p "Are you sure you want to update to ${VERSION}? [y/N] " response | |
if [[ "$response" =~ ^([nN])$ ]] | |
then | |
echo "Exiting..." | |
exit 0 | |
fi | |
# Clean up old | |
rm $PACKAGE-*.phar | |
rm $PACKAGE-*.pkg.tar.xz | |
wget https://github.com/${REPO}/releases/download/${VERSION}/$PACKAGE.phar | |
sed -i "s/pkgver=.*/pkgver=$VERSION/g" PKGBUILD | |
CHECKSUM=$(sha512sum $PACKAGE.phar | awk '{print $1}') | |
sed -i "s/sha512sums=('.*')/sha512sums=('$CHECKSUM')/g" PKGBUILD | |
git add PKGBUILD | |
echo "Done patching ${PACKAGE} to ${VERSION}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment