-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate-release-commit
More file actions
executable file
·122 lines (107 loc) · 2.75 KB
/
create-release-commit
File metadata and controls
executable file
·122 lines (107 loc) · 2.75 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash -eu
#
# Create a Debian package release commit
#
function usage()
{
cat <<EOF
Usage: create-release [-h] [-s SUFFIX] [-u] [PREV_REL_COMMIT]
Create a Debian package release commit.
Postional arguments:
PREV_REL_COMMIT Previous release commit.
Optional arguments:
-h, --help Show this help text and exit.
-s, --suffix SUFFIX Append SUFFIX to the current package version to generate
the new version rather than bumping the upload number.
-u, --ubuntu Force Ubuntu'ness.
EOF
}
suffix=
ubuntu=0
prev_release=
while [ "${#}" -gt 0 ] ; do
case "${1}" in
-h|--help)
usage
exit
;;
-s|--suffix)
shift
suffix=${1}
;;
-u|--ubuntu)
ubuntu=1
;;
*)
if [ -n "${prev_release}" ] ; then
echo "Invalid argument: ${1}" >&2
exit 2
fi
prev_release=${1}
;;
esac
shift
done
DEBIAN=debian
if [ -e debian/debian.env ] ; then
ubuntu=1
# shellcheck disable=SC1091
. debian/debian.env
fi
changelog=${DEBIAN}/changelog
src=$(dpkg-parsechangelog -l"${changelog}" -S Source)
version=$(dpkg-parsechangelog -l"${changelog}" -S Version)
dist=$(dpkg-parsechangelog -l "${changelog}" -S Distribution)
urgency=$(dpkg-parsechangelog -l"${changelog}" -S Urgency)
case "${src}" in
linux-firmware*)
ubuntu=1
ubuntu_prefix=
;;
esac
if [ "${dist}" != UNRELEASED ] ; then
# Add a new changelog entry
ubuntu_prefix=
if [ -z "${prev_release}" ] ; then
prev_release=$(git log --oneline -1000 | \
grep -m1 -P "^[0-9a-f]{12,} UBUNTU: Ubuntu(-.*)?-${version}$" || \
true)
ubuntu_prefix=${prev_release%-"${version}"}
ubuntu_prefix=${ubuntu_prefix#* Ubuntu}
prev_release=${prev_release%% *}
fi
if [ -z "${prev_release}" ] ; then
echo "Unable to find previous release commit" >&2
exit 1
fi
if [ -n "${suffix}" ] ; then
new_version=${version}${suffix}
else
upload=$(echo "${version}" | grep -oP '[0-9]+$')
new_version=${version%"${upload}"}$((upload + 1))
fi
{
echo "${src} (${new_version}) UNRELEASED; urgency=${urgency}"
echo
if [ ${ubuntu} -eq 1 ] ; then
git log "${prev_release}".. | git-ubuntu-log
else
git log --format=' * %s' --reverse "${prev_release}"..
fi
echo
echo " -- ${DEBFULLNAME} <${DEBEMAIL}> $(date -R)"
echo
cat "${changelog}"
} > "${changelog}".new
mv "${changelog}".new "${changelog}"
fi
# Close the release
dist=$(dpkg-parsechangelog -l "${changelog}" -S Distribution -o 1 -c 1)
dch --changelog "${changelog}" --release --distribution "${dist}" ""
# Commit the release
version=$(dpkg-parsechangelog -l"${changelog}" -S Version)
if [ ${ubuntu} -eq 1 ] ; then
git commit -s -m "UBUNTU: Ubuntu${ubuntu_prefix}-${version}" -- "${changelog}"
else
git commit -s -m "Release ${src} (${version})" -- "${changelog}"
fi