blob: 0ac02e4a3d3846dc056090ba4545ba879b278488 [file] [log] [blame]
avm99963f01af0e2020-12-26 23:11:10 +01001#!/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/translateselectedtext"
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
49commitMessage1="$nextVersion"
50commitMessage2="Changelog: $GITILES_REPO_URL/+log/refs/tags/$prevVersion..refs/tags/$nextVersion"
avm99963e74940e2021-02-02 23:47:16 +010051git tag -s $nextVersion -m "$commitMessage1" -m "$commitMessage2"
avm99963f01af0e2020-12-26 23:11:10 +010052
53echo "Tag created. Now run \`git push --tags\` to push the tags to the server."