summarylogtreecommitdiffstats
path: root/sync
blob: 66ee5fa45131efa621d0c897fb4f3f899c6f44c0 (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
37
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"