summarylogtreecommitdiffstats
path: root/release
blob: 1a0fd8dd1067ebc05067f457a903d3c9b79be796 (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
45
46
47
48
#! /bin/sh

if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ] || [ -z "$1" ]; then
  cat <<EOF
$ release VERSION
Prepare a new version for release

Parameters:
  \$1: version number of new release

Example:
  $ release 1337
EOF
  exit
fi

command -v wget >/dev/null || { echo "wget is not installed" 1>&2; exit 127; }
command -v makepkg >/dev/null || { echo "makepkg was not found" 1>&2; exit 127; }
command -v git >/dev/null || { echo "git is not installed" 1>&2; exit 127; }

VERSION="$1"

# update version nr
sed -r "s/^pkgver=.*$/pkgver=\"$VERSION\"/g" PKGBUILD -i

# upate shasum
URL=`sed -r "s/\\\\$\{pkgver\}/$VERSION/g" PKGBUILD | grep -Po '^source=\("\K.*(?=")'`
echo "computing shasum for $URL"
SHASUM=`wget "$URL" -qO - 2>/dev/null | sha256sum | cut -d\  -f1 | tr -d "\n"`
sed -r "s/^sha256sums=\([\"'][^\"']+[\"']\)$/sha256sums=(\"$SHASUM\")/" PKGBUILD -i

# regenerate .SRCINFO
makepkg -sf && makepkg --printsrcinfo > .SRCINFO

# check changes
git --no-pager diff PKGBUILD

# cleanup temp
rm -r src pkg *.tar.gz *.tar.zst 2>/dev/null

git status
printf "Commit and push changes? (Y/n): "
read ans
if [ "$ans" != "n" ] && [ "$ans" != "N" ]; then
  git add -A
  git commit -m "Release $VERSION"
  git push origin
fi