blob: 4992ecf975d96809c44f0882e61184fda7374a8e [file] [log] [blame]
avm999634c584882020-08-23 16:08:50 +02001#!/bin/bash
2#
3# Tags the current git HEAD as a new version, passed via a flag.
4
5GITILES_REPO_URL="https://gerrit.avm99963.com/plugins/gitiles/infinitegforums"
6
7# Prints help text
8function usage() {
9 cat <<END
10
11 Usage: $progname --version VERSION
12
13 required arguments:
14 -v, --version the version of the new release (in the form vx)
15 which wants to be tagged.
16
17 optional arguments:
18 -h, --help show this help message and exit
19
20END
21}
22
23opts=$(getopt -l "help,version:" -o "hv:" -n "$progname" -- "$@")
24eval set -- "$opts"
25
26prevVersion=$(git describe --abbrev=0)
27nextVersion="null"
28
29while true; do
30 case "$1" in
31 -h | --help)
32 usage
33 exit
34 ;;
35 -v | --version)
36 nextVersion="$2"
37 shift 2
38 ;;
39 *) break ;;
40 esac
41done
42
43if [[ $nextVersion == "null" ]]; then
44 echo "version parameter value is incorrect." >&2
45 usage
46 exit
47fi
48
avm999639ba01c42020-08-28 19:26:05 +020049commitMessage1="$nextVersion"
50commitMessage2="Changelog: $GITILES_REPO_URL/+log/refs/tags/$prevVersion..refs/tags/$nextVersion"
avm9996310729aa2021-02-02 23:46:11 +010051git tag -s $nextVersion -m "$commitMessage1" -m "$commitMessage2"
avm999634c584882020-08-23 16:08:50 +020052
avm99963de98f742021-02-18 19:06:28 +010053if [ $? -eq 0 ]; then
54 echo "Tag created. Now run \`git push --tags\` to push the tags to the server."
55else
56 echo "The tag could not be created." >&2
57fi