forked from mdev588/vboard
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupdate-version-number.sh
More file actions
executable file
·66 lines (51 loc) · 1.83 KB
/
Copy pathupdate-version-number.sh
File metadata and controls
executable file
·66 lines (51 loc) · 1.83 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
echo "Usage: $0 \"version.number\" \"changelog message\"" >&2
exit 1
fi
version="$1"
message="$2"
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
debian_changelog="${script_dir}/debian/changelog"
aur_pkgbuild="${script_dir}/AUR/PKGBUILD"
python_constants="${script_dir}/vboard/constants.py"
if [[ ! -f "${debian_changelog}" ]]; then
echo "Error: ${debian_changelog} not found" >&2
exit 1
fi
if [[ ! -f "${aur_pkgbuild}" ]]; then
echo "Error: ${aur_pkgbuild} not found" >&2
exit 1
fi
if [[ ! -f "${python_constants}" ]]; then
echo "Error: ${python_constants} not found" >&2
exit 1
fi
debian_version="${version}"
if [[ "${debian_version}" != *-* ]]; then
debian_version="${debian_version}-1"
fi
maintainer_signature="$(sed -n 's/^\s*\(-- .*>\)\s\{2,\}.*$/\1/p' "${debian_changelog}" | head -n 1)"
if [[ -z "${maintainer_signature}" ]]; then
echo "Error: could not determine maintainer signature from ${debian_changelog}" >&2
exit 1
fi
tmp_changelog="$(mktemp)"
tmp_pkgbuild="$(mktemp)"
tmp_constants="$(mktemp)"
trap 'rm -f "${tmp_changelog}" "${tmp_pkgbuild}" "${tmp_constants}"' EXIT
{
printf 'vboard (%s) unstable; urgency=medium\n\n' "${debian_version}"
printf ' * %s\n\n' "${message}"
printf ' %s %s\n\n' "${maintainer_signature}" "$(date -R)"
cat "${debian_changelog}"
} > "${tmp_changelog}"
mv "${tmp_changelog}" "${debian_changelog}"
sed "0,/^pkgver=.*/s//pkgver=${version}/" "${aur_pkgbuild}" > "${tmp_pkgbuild}"
mv "${tmp_pkgbuild}" "${aur_pkgbuild}"
sed "0,/^VERSION = \".*\"/s//VERSION = \"${version}\"/" "${python_constants}" > "${tmp_constants}"
mv "${tmp_constants}" "${python_constants}"
echo "Updated ${debian_changelog} to ${debian_version}"
echo "Updated ${aur_pkgbuild} to ${version}"
echo "Updated ${python_constants} to ${version}"