summarylogtreecommitdiffstats
path: root/update.sh
blob: be5d40dbc5da61169088d0bd72dfbc3ec944facc (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
29
30
#!/bin/bash

latest_version=$(curl -Is "https://github.com/snyk/cli/releases/latest" | grep "location" | head -1 | sed "s#.*tag/v##g" | tr -d "\r")
echo "Latest Snyk CLI 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}"

  snyk --version

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