summarylogtreecommitdiffstats
path: root/update_version.sh
blob: c643a8d1cfcf7718022b76bb185af9b78d0792f1 (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
49
50
51
52
53
#!/bin/bash
set -euxo pipefail

REPO="https://github.com/yggdrasil-network/yggdrasil-go.git"
WORKDIR="/tmp/yggdrasil-go"

# Set up cleanup
function cleanup() {
	rm -rf ${WORKDIR}
}
trap cleanup EXIT

# Check out latest master
git clone ${REPO} ${WORKDIR}

# Fetch version information
pushd ${WORKDIR}
git checkout develop

VER=$(git describe --tags --long --always)
VER=${VER/-/.r}
VER=${VER/-/.}
VER=${VER#v}

COMMIT=$(git rev-parse HEAD)

# Replace version in PKGBUILD
popd
sed -i \
	-e "s/^pkgver=.*$/pkgver=${VER}/" \
	-e "s/^_commit=.*$/_commit=${COMMIT}/" \
	PKGBUILD

# Check for real updates
if (git diff --exit-code PKGBUILD); then
	echo "Version ${VER} is already in PKGBUILD, not updating"
	exit 0
fi

# Reset pkgrel
sed -i \
	-e 's/pkgrel=.*/pkgrel=1/' \
	PKGBUILD

# Update source hashes
updpkgsums

# Update .SRCINFO
makepkg --printsrcinfo >.SRCINFO

# Create update-commit
git add PKGBUILD .SRCINFO
git commit -m "yggdrasil-go v${VER}"