summarylogtreecommitdiffstats
path: root/update.sh
blob: 71479f11658a1e8c01e1aa832202bb06144d996b (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
31
32
33
34
35
36
#!/bin/sh

set -e

SCRIPT_DIR="$(dirname "$0")"
cd "$SCRIPT_DIR"

source ./PKGBUILD

#VERSION="$(curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${_repo}/tags" 2>/dev/null | jq -r '.[0].name')"
#VERSION="$(curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${_repo}/releases/latest" 2>/dev/null | jq -r '.tag_name')"
#VERSION="$(curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${_repo}/tags" 2>/dev/null | jq -r '.[0].name' | cut -c 2-)"
VERSION="$(curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${_repo}/releases/latest" 2>/dev/null | jq -r '.tag_name' | cut -c 2-)"

if [ "${pkgver}" = "${VERSION}" ]; then
  echo "${pkgname}: No updates"
  exit
fi

echo "${pkgname}: ${pkgver} -> ${VERSION}"

if [ "$1" = "--check" ]; then
  exit
fi

# Update
sed -i -e "s/^pkgver=.*\$/pkgver='${VERSION}'/" -e "s/^pkgrel=.*\$/pkgrel=1/" PKGBUILD
updpkgsums
makepkg --printsrcinfo > .SRCINFO

# Build and install
makepkg -sicr

# Commit
git add .
git commit -m "update to ${VERSION};"