-
Notifications
You must be signed in to change notification settings - Fork 12
/
mk-git-tags.sh
executable file
·69 lines (60 loc) · 2.58 KB
/
mk-git-tags.sh
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
#!/bin/bash
#
# Creates tags for all repos that should be included in a Scala IDE product.
#
# Example call of this script:
#
# ./mk-git-tags.sh config/release-41x-211-luna.conf /path/to/repos "Scala IDE 4.1.0-RC1 release"
CONFIG_FILE=$1
BASE_DIR=$2
SIGN_MESSAGE=$3 #"Scala IDE 4.1.0-RC1 release"
# Check if CONFIG_FILE is a file
[ -z "$CONFIG_FILE" ] && echo "error: no config file specified" && exit 1
[ ! -f "$CONFIG_FILE" ] && echo "error: invalid config file" && exit 1
# Check if BASE_DIR is a directory
[ -z "$BASE_DIR" ] && echo "error: no base directory specified" && exit 1
[ ! -d "$BASE_DIR" ] && echo "error: invalid base directory" && exit 1
# Check if SIGN_MESSAGE is empty
[ -z "$SIGN_MESSAGE" ] && echo "error: no message for git tag signing specified" && exit 1
# Chick that only two parameters are passed
[ -n "$4" ] && echo "error: only two parameters allowed" && exit 1
source $CONFIG_FILE
SCALA_IDE_DIR="$BASE_DIR/scala-ide"
WORKSHEET_PLUGIN_DIR="$BASE_DIR/scala-worksheet"
PLAY_PLUGIN_DIR="$BASE_DIR/scala-ide-play2"
LAGOM_PLUGIN_DIR="$BASE_DIR/lagom-eclipse-plugin"
SEARCH_PLUGIN_DIR="$BASE_DIR/scala-search"
PRODUCT_DIR="$BASE_DIR/scala-ide-product"
# Check if all necessary repos exist
[ ! -d "$SCALA_IDE_DIR" ] && echo "error: $SCALA_IDE_DIR does not exist" && exit 1
[ ! -d "$WORKSHEET_PLUGIN_DIR" ] && echo "error: $WORKSHEET_PLUGIN_DIR does not exist" && exit 1
[ ! -d "$PLAY_PLUGIN_DIR" ] && echo "error: $PLAY_PLUGIN_DIR does not exist" && exit 1
[ ! -d "$LAGOM_PLUGIN_DIR" ] && echo "error: $LAGOM_PLUGIN_DIR does not exist" && exit 1
[ ! -d "$PRODUCT_DIR" ] && echo "error: $PRODUCT_DIR does not exist" && exit 1
# Creates the tag that is specified in CONFIG_FILE or do nothing if it already exist.
#
# $1 - repo directory to move to
# $2 - git tag name
# $3 - git tag sign message
function createTag() {
echo ""
echo ">>> Handle repo: `basename $1`"
cd "$1"
# check if tag already exists
if git rev-parse "$2" > /dev/null 2>&1; then
echo ">>> Tag $2 already exists"
else
echo ">>> Create tag $2"
git tag -s -m "$3" "$2"
git push origin "$2"
fi
}
echo ">>> All checks successful. Starting to create tags now."
createTag "$SCALA_IDE_DIR" "$SCALA_IDE_GIT_BRANCH" "$SIGN_MESSAGE"
createTag "$WORKSHEET_PLUGIN_DIR" "$WORKSHEET_PLUGIN_GIT_BRANCH" "$SIGN_MESSAGE"
createTag "$PLAY_PLUGIN_DIR" "$PLAY_PLUGIN_GIT_BRANCH" "$SIGN_MESSAGE"
createTag "$LAGOM_PLUGIN_DIR" "$LAGOM_PLUGIN_GIT_BRANCH" "$SIGN_MESSAGE"
createTag "$SEARCH_PLUGIN_DIR" "$SEARCH_PLUGIN_GIT_BRANCH" "$SIGN_MESSAGE"
createTag "$PRODUCT_DIR" "$PRODUCT_GIT_BRANCH" "$SIGN_MESSAGE"
echo ""
echo ">>> success"