summarylogtreecommitdiffstats
path: root/update_version.sh
blob: 1d5ea7d7850698922196e2a59bb10358d988e074 (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
#!/bin/bash
set -euxo pipefail

obs_version=$(curl -sSfL "https://git.archlinux.org/svntogit/community.git/plain/trunk/PKGBUILD?h=packages/obs-studio" | awk -F '=' '/^pkgver=/{print $2}')
sink_version=$(curl -sSfL "https://lv.luzifer.io/catalog-api/obs-v4l2sink/latest.txt?p=version")

[ -n "${obs_version}" ] && [ -n "${sink_version}" ] || {
	echo "Unable to find current versions"
	exit 1
}

# First update OBS version
grep -q "^obsver=${obs_version}$" PKGBUILD || {
	pkgrel=$(($(awk -F '=' '/^pkgrel=/{print $2}' PKGBUILD) + 1))
	sed -i \
		-e "s/^obsver=.*/obsver=${obs_version}/" \
		-e "s/pkgrel=.*/pkgrel=${pkgrel}/" \
		PKGBUILD
}

# In case there is a release, update the release version
grep -q "^pkgver=${sink_version}$" PKGBUILD ||
	sed -i \
		-e "s/^pkgver=.*/pkgver=${sink_version}/" \
		-e 's/pkgrel=.*/pkgrel=1/' \
		PKGBUILD

# Check whether this changed anything
if (git diff --exit-code PKGBUILD); then
	echo "Package has most recent version ${sink_version} and OBS version ${obs_version}"
	exit 0
fi

updpkgsums

# Update .SRCINFO
makepkg --printsrcinfo >.SRCINFO

# Commit changes
git add PKGBUILD .SRCINFO
git commit -m "obs-v4l2sink v${sink_version} / obs-studio v${obs_version}"