summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dulaney2019-08-09 00:14:30 -0400
committerDaniel Dulaney2019-08-09 00:14:30 -0400
commit4bae3704237a69dd9af951102cfe574a157efa1b (patch)
tree31099975e3935f78a546ef20ea44450b9e747c21
parent9f129dd55f5cc134f06ed71770e1b7d212f3aa3f (diff)
downloadaur-4bae3704237a69dd9af951102cfe574a157efa1b.tar.gz
Added update script
-rw-r--r--.gitignore1
-rwxr-xr-xupdate.sh46
2 files changed, 47 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 0a3deca80568..4aec91a49d4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
!.gitignore
!PKGINFO
!.SRCINFO
+!update.sh
diff --git a/update.sh b/update.sh
new file mode 100755
index 000000000000..90662dc571e5
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,46 @@
+#! /usr/bin/env bash
+
+current_ver=$(echo 'echo $pkgver' | cat PKGBUILD - | bash)
+latest_ver=$(curl -Ls https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest | jq -r .tag_name)
+
+echo "Potential upgrade $current_ver -> $latest_ver"
+
+if [ "$current_ver" == "$latest_ver" ]; then
+ echo "Up-to-date ($latest_ver)"
+ exit
+elif [ $(printf "$current_ver\n$latest_ver" | sort -Vr | head -n 1) != "$latest_ver" ]; then
+ echo "Latest version on GitHub ($latest_ver) is earlier than current ($current_ver)"
+ echo "Exiting in confusion"
+ exit 1
+fi
+
+echo "Performing upgrade..."
+
+# Update PKGBUILD version
+sed -i "s/pkgver=.*/pkgver=$latest_ver/" PKGBUILD
+
+# Update checksums
+sed -i "s/sha256sums=.*/$(makepkg --geninteg)/" PKGBUILD
+
+# Update srcinfo
+makepkg --printsrcinfo > .SRCINFO
+
+# Confirm that package builds
+if ! makepkg -f; then
+ echo "Error in makepkg; exiting"
+ exit 1
+fi
+
+echo "Successfully built! Committing to Git"
+
+# Git commit
+git commit -am "Updated to $latest_ver"
+
+echo "Pushing..."
+
+if ! git push; then
+ echo "Could not push to AUR"
+ exit 1
+fi
+
+echo "Update complete"