avm99963 | 4c58488 | 2020-08-23 16:08:50 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Tags the current git HEAD as a new version, passed via a flag. |
| 4 | |
| 5 | GITILES_REPO_URL="https://gerrit.avm99963.com/plugins/gitiles/infinitegforums" |
| 6 | |
| 7 | # Prints help text |
| 8 | function 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 | |
| 20 | END |
| 21 | } |
| 22 | |
| 23 | opts=$(getopt -l "help,version:" -o "hv:" -n "$progname" -- "$@") |
| 24 | eval set -- "$opts" |
| 25 | |
| 26 | prevVersion=$(git describe --abbrev=0) |
| 27 | nextVersion="null" |
| 28 | |
| 29 | while 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 |
| 41 | done |
| 42 | |
| 43 | if [[ $nextVersion == "null" ]]; then |
| 44 | echo "version parameter value is incorrect." >&2 |
| 45 | usage |
| 46 | exit |
| 47 | fi |
| 48 | |
| 49 | commitMessage="Changelog: $GITILES_REPO_URL/+log/refs/tags/$prevVersion..refs/tags/$nextVersion" |
| 50 | git tag -a $nextVersion -m "$commitMessage" |
| 51 | |
| 52 | echo "Tag created. Now run \`git push --tags\` to push the tags to the server." |