summarylogtreecommitdiffstats
path: root/update.sh
blob: 46890761cf17456ec26f24dc49d933adff934719 (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
39
40
41
42
43
44
#!/bin/bash
set -e
set -o pipefail

HASH=b2sum
HASH_NAME=b2sums

source PKGBUILD
PKGNAME=$_name
RELEASES=$(curl -sL https://pypi.org/pypi/$PKGNAME/json | jq .releases)
LAST=$(jq -r <<<$RELEASES '
[ keys[]
    | select(contains("beta") == false)
    | select(contains("rc") == false)
    | select(contains("a") == false)
    | select(contains("b") == false)
    | select(contains("c") == false)
    | select(contains("d") == false)
    | [split(".")[] | tonumber] ]
  | sort[-1]
  | join(".")
' || (echo $RELEASES > resp.err && exit 1))

if [ "$pkgver" == "$LAST" ]; then
    echo "Already up to date" >&2
    exit 0
fi

TAG=py-$LAST

DOWNLOAD_URL="https://github.com/pola-rs/polars/archive/refs/tags/$TAG.tar.gz"
SUM=$( (curl -sfL $DOWNLOAD_URL | $HASH - | cut -d' ' -f1) || (echo "Error fetching $DOWNLOAD_URL" >&2 && exit 1) )

sed -i 's/.*sums=.*$/'$HASH_NAME'=("'$SUM'")/' PKGBUILD
sed -i 's/pkgver=.*/pkgver='$LAST'/' PKGBUILD
sed -i 's/pkgrel=.*/pkgrel=1/' PKGBUILD

# Make sure it builds fine
makepkg
rm *.tar.*

git add PKGBUILD
git commit -m "Update to $LAST"
git push