summarylogtreecommitdiffstats
path: root/update.sh
blob: 64ea5ce8fb9f8cd97720185a273a02c5c594e0ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

latest_version=$(curl -Is "https://github.com/smlx/piv-agent/releases/latest" | grep "location" | head -1 | sed "s#.*tag/v##g" | tr -d "\r")
echo "Latest piv-agent version: v${latest_version}"

sed -i "s/^pkgver=.*$/pkgver=${latest_version}/" ./PKGBUILD

if ! git diff --quiet HEAD PKGBUILD; then

  if pacman -Qi pacman-contrib > /dev/null 2>&1; then
    updpkgsums
  else
    echo "Install pacman-contrib with 'pacman -S pacman-contrib'"
    exit 1
  fi

  makepkg --printsrcinfo > .SRCINFO

  makepkg -si

  git add PKGBUILD .SRCINFO

  git commit -m "Updated version to ${latest_version}"

  git push origin master
else
  echo "No updates found!"
fi