blob: 4f4f8b70e5441ee7d998d81509283204d39e69e9 [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
53echo "Tag created. Now run \`git push --tags\` to push the tags to the server."