summarylogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
Diffstat (limited to 'sync')
-rwxr-xr-xsync38
1 files changed, 38 insertions, 0 deletions
diff --git a/sync b/sync
new file mode 100755
index 000000000000..66ee5fa45131
--- /dev/null
+++ b/sync
@@ -0,0 +1,38 @@
+#!/usr/bin/bash
+
+#shellcheck disable=SC1091
+. ./PKGBUILD
+
+# Get info.
+# shellcheck disable=SC2154
+username=$(echo "$url" | cut -d '/' -f 4)
+# shellcheck disable=SC2154
+release=$(curl -s https://api.github.com/repos/"${username}"/"${pkgname}"/releases/latest)
+tag_name=$(jq -r .tag_name <<< "$release")
+version=${tag_name/v/}
+
+# Check versions.
+# shellcheck disable=SC2154
+if [ "$pkgver" == "$version" ]; then
+ echo "${pkgname}-${pkgver} is up to date. latest version: ${version}"
+ exit 0
+fi
+
+# Extract new version info.
+tarball=$(jq -r .tarball_url <<< "$release")
+sha256sum_raw=$(wget -q -nv --no-cache -c "$tarball" -O- | sha256sum | sed 's/ //g')
+sha256sum="${sha256sum_raw%-}"
+
+# Update PKGBUILD and .SRCINFO files.
+sed -i -e "s/pkgver=.*$/pkgver=${version}/g" -e "s/sha256sums=.*$/sha256sums=('${sha256sum}')/g" PKGBUILD
+makepkg --printsrcinfo > .SRCINFO
+
+# Run build just for testing.
+makepkg
+
+# Commit and push changes.
+git commit -m "Upgrade to version ${version}" PKGBUILD .SRCINFO
+git push
+
+# Logging final result.
+echo "Update ${pkgname} from ${pkgver} to ${version} version in AUR"