summarylogtreecommitdiffstats
path: root/update.sh
blob: fe60cddf716a7de769a43097c9629dc442213e9b (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

set -eo pipefail

build_ver=`grep ^pkgver= PKGBUILD | cut -d= -f2`
release_ver=`curl --silent 'https://api.github.com/repos/ansible-collections/community.general/releases/latest' | jq -r .tag_name`
new_ver=`echo -e "$release_ver\n$build_ver" | sort -rV | head -n 1`

if [ $new_ver = $build_ver -a "${initial}x" = "x" ] ; then
    exit
fi

if [ "${initial}x" = "x" ] ; then
    echo "New version available: $new_ver (last build is $build_ver)"
    sed -i -e "s/^pkgver=.*/pkgver=$new_ver/" PKGBUILD
    sed -i -e "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
    updpkgsums -m
else
    cd ..
    echo "Building version $build_ver (initial)"
fi

echo "Building package"
makepkg --skippgpcheck -CcLm | tee build.log

# Build is successful, will push to aur
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO
git commit -m "Released $new_ver-1"
git push