summarylogtreecommitdiffstats
path: root/newrel.sh
blob: 02e53136aaf5f7974fab68eb485581cd23b28ff2 (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
#!/bin/bash

set -e

# Get rast release version for PKGBUILD file
VERSION=$(curl --silent https://api.github.com/repos/schmidtandreas/wofi-pass/releases/latest | grep "tag_name" | cut -d ":" -f 2 | sed "s|.*\"\(.*\)\".*|\1|")
test -n "${VERSION}"

# Update PKGBUILD file
wget "https://github.com/schmidtandreas/wofi-pass/releases/download/${VERSION}/wofi-pass" -O "app"
wget "https://github.com/schmidtandreas/wofi-pass/releases/download/${VERSION}/wofi-pass.1.gz" -O "manpage"
CHECKSUM_app=$(sha512sum app | awk '{ print $1 }')
CHECKSUM_manpage=$(sha512sum manpage | awk '{ print $1 }')
sed -i "s|sha512sums.*|sha512sums=('${CHECKSUM_app}\n             ${CHECKSUM_manpage}')|" PKGBUILD
rm app manpage

# Increase pkgrel if version is not changed
CURRENT_VERSION="$(cat .SRCINFO | grep pkgver | cut -d "=" -f 2 | sed "s|^[[:space:]]*||")"
if [[ "${VERSION}" == "${CURRENT_VERSION}" ]]; then
    CURRENT_PKGREL=$(cat .SRCINFO | grep pkgrel | cut -d "=" -f 2 | sed "s|^[[:space:]]*||")
    sed -i "s|pkgrel.*|pkgrel=$((CURRENT_PKGREL + 1))|" PKGBUILD
fi

# Update source info
makepkg --printsrcinfo > .SRCINFO

# Monky Test
makepkg -sri

# Cleanup
[ -d pkg ] && rm -fr pkg
[ -d src ] && rm -fr src
[ -f wofi-pass ] && rm wofi-pass
[ -f wofi-pass.1.gz ] && rm wofi-pass.1.gz